我有此Windows服务用于发送消息:
private System.Threading.Timer _worker;
private int _whatsAppInterval;
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
if (ConfigurationManager.AppSettings["WhatsAppInterval"] != null)
{
_whatsAppInterval = Convert.ToInt32(ConfigurationManager.AppSettings["WhatsAppInterval"].ToString());
}
else
{
_whatsAppInterval = 6000;
}
System.Console.WriteLine("O servico iniciou.");
_worker = new System.Threading.Timer((WhatsAppService), null, 0, _whatsAppInterval);
}
如何让它在重新开始之前等待请求完成?