public void Dispose()
{
this.Log().DebugWithLineNumber("Start disposing.");
if (CancellationTokenSource != null &&
!CancellationTokenSource.IsCancellationRequested)
{
CancellationTokenSource.Cancel();
}
if (MyAppDomain != null)
{
try
{
AppDomain.Unload(MyAppDomain);
}
catch (Exception)
{
}
}
if (Task != null)
{
Task.Dispose();
}
this.Log().DebugWithLineNumber("Finshed disposing.");
}