delaying the sending of email messages without using Thread.Sleep c#

后端 未结 4 1777
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 04:14

I have a for loop which loops through and sends an email each loop. Right now im using thread.sleep() but I want the user to still be able to interact with the program, just del

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-29 05:08

    You need to put the method of sending mail in separated thread to keep your GUI interactive .

    Thread newThread = new Thread(new ThreadStart(SendMail));
    newThread.Start();
    
    public void SendMail() 
    {
        //Send mails here       
    }
    

提交回复
热议问题