我现在在python#中嵌入pythonnet。当我调用耗时长的python函数时,我希望python函数将进程通知给c#调用者,我该怎么办?
环境: Python 3.6,C#
示例:
C#代码
public class TestCallback
{
public void CheckingProcess(int step)
{
//do some notify
}
public void CallPython()
{
using (Py.GIL())
{
long_time_worker(CheckingProcess);
}
}
}
Python代码
def long_time_worker(callback):
'callback: c# function'
for i in range(1000):
#do some work.......
callable(i) #notify current step to caller