CEL_Payroll/Ease.SvcHost/HostService.cs

76 lines
1.5 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.ComponentModel;
namespace Ease.SvcHost
{
[ToolboxItem(false)]
public class HostService : ServiceBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private RemotingHost _host;
private System.ComponentModel.Container components = null;
public HostService(string name)
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
base.ServiceName = name;
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// RemotingHostService
//
this.ServiceName = "ServiceHost";
}
#endregion
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
_host = new RemotingHost();
_host.Start();
EventLog.WriteEntry(_host.Status);
}
/// <summary>
/// Stop this service.
/// </summary>
protected override void OnStop()
{
_host.Stop();
EventLog.WriteEntry(_host.Status);
}
}
}