本文整理汇总了C#中ServiceController.UnloadService方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceController.UnloadService方法的具体用法?C# ServiceController.UnloadService怎么用?C# ServiceController.UnloadService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceController
的用法示例。
在下文中一共展示了ServiceController.UnloadService方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestExceptionLogged
public void TestExceptionLogged()
{
var service = new ServiceController() {
ServiceDomain = AppDomain.CreateDomain("Potato.Instance"),
UnloadServiceBegin = controller => {
throw new Exception("Empty");
},
Process = new MockProcess()
};
service.UnloadService();
Assert.IsNotEmpty(Defines.ErrorsLogsDirectory.GetFiles());
Assert.Greater(Defines.ErrorsLogsDirectory.GetFiles().First().Length, 0);
service.Dispose();
}
示例2: TestExceptionKillsProcess
public void TestExceptionKillsProcess()
{
var process = new MockProcess();
var service = new ServiceController() {
ServiceDomain = AppDomain.CreateDomain("Potato.Instance"),
UnloadServiceBegin = controller => {
throw new Exception("Empty");
},
Process = process
};
service.UnloadService();
Assert.IsTrue(process.OnKill);
service.Dispose();
}
示例3: TestServiceDomainNulled
public void TestServiceDomainNulled()
{
var service = new ServiceController() {
ServiceDomain = AppDomain.CreateDomain("Potato.Instance"),
};
service.UnloadService();
Assert.IsNull(service.ServiceDomain);
service.Dispose();
}
示例4: TestUnloadServiceDispatchedEndDelegateCalled
public void TestUnloadServiceDispatchedEndDelegateCalled()
{
var end = false;
var service = new ServiceController() {
ServiceDomain = AppDomain.CreateDomain("Potato.Instance"),
UnloadServiceEnd = controller => end = true
};
service.UnloadService();
Assert.IsTrue(end);
service.Dispose();
}
示例5: TestUnloadServiceDispatchedBeginDelegateCalled
public void TestUnloadServiceDispatchedBeginDelegateCalled()
{
var begin = false;
var service = new ServiceController() {
ServiceDomain = AppDomain.CreateDomain("Potato.Instance"),
UnloadServiceBegin = controller => begin = true
};
service.UnloadService();
Assert.IsTrue(begin);
service.Dispose();
}