Can this code provocate a deadlock? I am afraid that the handler is executed suddenly in the middle of the execution of the DoWork function (which is also locked).
private object lockObject = new object();
public void DoWork()
{
lock(lockObject)
{
ChannelFactory<TChannel> channelFactory = CreateChannelFactory();
channelFactory.Faulted += (sender, e) => OnChannelFactoryFaulted(sender, e);
// Some code.. access to dictionary...
}
}
private void OnChannelFactoryFaulted(object sender, EventArgs e)
{
lock (lockObject)
{
// Some code.. access to dictionary..
}
}
Thanks