I was using code like this:
handler.Invoke(sender, e);
But the problem with that code is that it is synchronous and all it really does is update the GUI. It is not necessary for the server to wait for it to complete so it should be made asynchronous.
I don’t really want to use BeginInvoke and EndInvoke because a callback method is not necessary in this case.
Is this a suitable alternative?
Task.Factory.StartNew(() => handler.Invoke(sender, e));
The way you did it is fine, another way to do this that works on .NET 3.5 is using the
ThreadPoolclass insteadAlso if handler happens to be a derived from control, you are allowed to call BeginInvoke without a corresponding EndInvoke.