Reputation: 767
lock
{
Dispatcher.BeginInvoke(DispatcherPriority.Send, (SendOrPostCallback)delegate(object o)
{
DoSomething();
}
}
Does lock remains acquired Until Dispatcher completes its execution or released soon after sending the DoSomething(); for execution to Dispatcher?
Upvotes: 2
Views: 1089
Reputation: 4567
lock {}
section completes its execution. Dispatcher.BeginInvoke
completes its execution. Dispatcher.BeginInvoke
executes asynchronously, that means that lock gets released almost "immediately" - DoSomething()
might start in the moment when lock has been already released.Upvotes: 2