mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-22 05:10:29 +03:00
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.ServiceModel;
|
|
using NAPS2.Logging;
|
|
using NAPS2.Util;
|
|
|
|
namespace NAPS2.Worker
|
|
{
|
|
/// <summary>
|
|
/// A class storing the objects the client needs to use a NAPS2.Worker.exe instance.
|
|
/// </summary>
|
|
public class WorkerContext : IDisposable
|
|
{
|
|
public IWorkerService Service { get; set; }
|
|
|
|
public IWorkerCallback Callback { get; set; }
|
|
|
|
public Process Process { get; set; }
|
|
|
|
public void Dispose()
|
|
{
|
|
try
|
|
{
|
|
((IDisposable) Service)?.Dispose();
|
|
}
|
|
catch (CommunicationObjectFaultedException)
|
|
{
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.ErrorException("Error cleaning up worker", e);
|
|
}
|
|
try
|
|
{
|
|
Process.Kill();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.ErrorException("Error cleaning up worker", e);
|
|
}
|
|
}
|
|
}
|
|
}
|