WORKER CLASS1:
public override void Process(Crawler crawler, PropertyBag propertyBag)
{
SynchronizationContext uiContext = SynchronizationContext.Current;
Thread thread = new Thread(ThreadFunc);
}
void ThreadFunc(object state)
{
var syncContext = state as SynchronizationContext;
syncContext.Send(new Action(() => {
using (GeckoBrowserForm geckoBrowserForm = new GeckoBrowserForm ("http//www.google.com"))
{
geckoBrowserForm.ShowDialog();
while (!geckoBrowserForm.Done)
{
Application.DoEvents();
}
other code
}
}), null);
}
但我總是得到參數「System.Action」是不能分配給參數類型「System.Threading.SendOrPostCallback」
「參數‘System.Action’是不能分配給參數類型 「 System.Threading.SendOrPostCallback'」
我想,每一個Process
都會有自己的SynchronizationContext
,然後用一些邏輯執行UIS主題。
UI THREAD CLASS2:
protected override void OnLoad(EventArgs e)
{
...
String val = "Some value";
Done = true;
and return back `val` to the `CLASS1`
}
這是可能的嗎?