I\'ve this little method which is supposed to be thread safe. Everything works till i want it to have return value instead of void. How do i get the return value when BeginI
Is something like this what you wanted?
// begin execution asynchronously
IAsyncResult result = myObject.BeginInvoke("data.dat", null, null);
// wait for it to complete
while (result.IsCompleted == false) {
// do some work
Thread.Sleep(10);
}
// get the return value
int returnValue = myObject.EndInvoke(result);