How do I use "StartService" Task with ThreadStart? Is it possible?
public partial class MyService : ServiceBase
{
public MyService()
{
InitializeComponent();
LocalInit();
}
internal void LocalInit()
{
//place here any local checks
}
protected override void OnStart(string[] args)
{
if (Something.ConfigOK())
{
ThreadStart threadDelegate = Something.StartService; // Expected a method with void StartService signature
var newThread = new Thread(threadDelegate);
newThread.Start();
}
else
{
//log error
throw new Exception("MyService : Config failed");
}
}
}
public static partial class Something
{
public static async Task StartService()
{
await DoJob();
}
}
Errors
Error CS0407 'Task Something.StartService()' has the wrong return type
Expected a method with void StartService signature