在将Windows API(包括数据类型)转换为P/Invoke时,我应该用int或替换DWORD uint吗?
它通常是未签名的,但我看到人们int在任何地方使用它(只是因为CLS警告?甚至.NET Framework本身都这样做),所以我从来不确定哪一个是正确的使用它.
请您帮我弄清楚为什么我的服务在事件日志中报告以下错误消息:
[服务名称] 服务报告了无效的当前状态 0。
这是我的主要功能:
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
// Setup Ninject
var kernel = ConfigureNinject();
#if DEBUG
var service = kernel.Get<UpdateTakerStatus>();
service.onDebug();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#else
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
kernel.Get<UpdateTakerStatus>()
};
ServiceBase.Run(ServicesToRun);
#endif
}
}
Run Code Online (Sandbox Code Playgroud)
...这是我的UpdateTakerStatus课程,我的逻辑在一个新线程中被调用:
public partial class UpdateTakerStatus : ServiceBase
{
private Thread WorkerThread;
private AutoResetEvent StopRequest = new AutoResetEvent(false);
private ServiceStatus serviceStatus = new ServiceStatus();
public …Run Code Online (Sandbox Code Playgroud)