private IntPtr EstablishContextIfNotEstablished()
{
var establishContextResult = EstablishContext();
if (!establishContextResult.IsSuccessful)
throw new Exception(
string.Format("Exception during context establishing for current thread ({0}). Error code: {1}",
Thread.CurrentThread.ManagedThreadId, establishContextResult.StatusCode));
var currentThreadContext = _contextManager.GetContext(Thread.CurrentThread.ManagedThreadId);
return currentThreadContext;
}