I need to know whether Control.BeginInvoke and Control.Invoke calls will execute in the order they are called.
I have the following scenario:
The execution order of step 1-4 is guaranteed to be in the shown order (technically the order is not guaranteed to be that way, but the question I have is only relevant if the order is as shown).
The question I have is whether there is any chance that the Invoke/BeginInvoke call in step 3 is executed before the BeginInvoke call in step 2?
Also, please don't comment on blocking the UI thread.
In your case, step 2 will always execute before step 3. BeginInvoke on the UI thread will execute in the order it has been queued.
The UI thread is in fact a message pump, it has a single message queue with only one thread consuming it, so it's guaranteed that work items will be executed in the order they were queued.
It's with Delegate.BeginInvoke that the order of execution may be non-sequential.
BeginInvoke calls are queued on the destination thread (as they are posted in order of arrival).
Synchronous calls on the WCF Thread (step 3) may be executed before asynchronous calls (step 2) made from this thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With