C
Carl
Hi,
Are there any practial differences in execution between these to
alternatives? As far as I understand, they should execute exactly
the same, is that correct?
Alt1:
=======
private Semaphore _semaphoreTest = new Semaphore(1, 1, "SemaphoreTest");
try
{
_semaphoreTest.WaitOne();
sender.SendTest(Data, Stuff);
}
catch (Exception ex)
{
Log.Instance.LogAll(ex.Message + Environment.NewLine);
Log.Instance.LogAll(ex.StackTrace);
}
finally
{
_semaphoreTest.Release();
}
Alt2:
=======
private static Object _lock = new Object();
lock(_lock)
{
try
{
sender.SendTest(Data, Stuff);
}
catch (Exception ex)
{
Log.Instance.LogAll(ex.Message + Environment.NewLine);
Log.Instance.LogAll(ex.StackTrace);
}
}
Thanks in advace,
Carl
Are there any practial differences in execution between these to
alternatives? As far as I understand, they should execute exactly
the same, is that correct?
Alt1:
=======
private Semaphore _semaphoreTest = new Semaphore(1, 1, "SemaphoreTest");
try
{
_semaphoreTest.WaitOne();
sender.SendTest(Data, Stuff);
}
catch (Exception ex)
{
Log.Instance.LogAll(ex.Message + Environment.NewLine);
Log.Instance.LogAll(ex.StackTrace);
}
finally
{
_semaphoreTest.Release();
}
Alt2:
=======
private static Object _lock = new Object();
lock(_lock)
{
try
{
sender.SendTest(Data, Stuff);
}
catch (Exception ex)
{
Log.Instance.LogAll(ex.Message + Environment.NewLine);
Log.Instance.LogAll(ex.StackTrace);
}
}
Thanks in advace,
Carl