Possible duplicates:
Should every BeginInvoke follow EndInvoke?
Is EndInvoke () optional, sorting optional or definitely optional?
I have a multi-threaded application, and one of the minor threads should get some code to execute on the main thread every couple of minutes. There is no return value, and the second thread does not care that it throws any exceptions or does not start.
So far, I have run it to run the code through Form.Invoke , but sometimes it takes much longer than usual (a couple of seconds) and blocks the thread until it completes. I need a second thread to continue execution without stopping for a few seconds.
BeginInvoke sounds like it did the job beautifully, but I really have nothing to call EndInvoke , since I don't want to wait for it or get the return value. And given that the code being called includes a bunch of native calls, I'm not sure if this is a good idea not EndInvoke .
Do I need to call EndInvoke at all, or is there some other way to get the code to run the stream in the main form asynchronously, what should I use instead?
Thanks =)
source share