Windows服务-等待请求完成,然后再次启动

时间:2020-07-29 14:47:30

标签: multithreading windows-services task

我有此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);
    }

如何让它在重新开始之前等待请求完成?

0 个答案:

没有答案