Hi,
this may be a stupid question:
How can I can call the DoWork-function of a BackgroundWorker
synchronous?
Or in other words:
How can I extend the BackgroundWorker class with a function
RunWorkerSync()?
I want to write a class that I can call functions synchronous and
asynchronous.
e.g.
This is the code for running the function DoWork asynchronous
(incomplete);
void TestAsync()
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += DoWork;
worker.RunWorkerCompleted += RunWorkerCompleted;
...
worker.RunWorkerAsync(Param);
...
}
void DoWork(object sender, DoWorkEventArgs e)
{
Object Param = (Object) e.Argument;
// do something
e.Result = something;
}
void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
m_Result = (Object) e.Result;
}
This is the code for running synchronous (incomplete);
void TestSync()
{
// call synchronous
m_Result = DoWork(Object Param);
}
How can I combime this?
Thanks for your help!