Troubleshooting: No multiple downloads are eligible for System.Timers.ElapsedEventHandler delegation

Source: Internet
Author: User

This is one of the last key features in the actual case: Reminder notifications

The strange situation encountered

The current setup is to combine a Timer with a Windows Form, which is the download for sending notifications

As we all know, there are three built-in timer available in C # Environment: Windows Form Timer, System.timer, Threading.timer

The strange things that are encountered, mainly in System.timer this section

The codes are as follows:

usingSystem;usingSystem.Drawing;usingSystem.Text;usingSystem.Threading;usingsystem.timers;usingSystem.Windows.Forms;namespacesystemtimer{ Public Partial classForm1:form {intNumber =0; DateTime DT1=NewDateTime (); DateTime DT2=NewDateTime ();        System.Timers.Timer TM;  PublicForm1 () {InitializeComponent (); }        Private voidForm1_Load (Objectsender, EventArgs e) {        }        Private voidB1_click (Objectsender, EventArgs e) {TM=NewSystem.Timers.Timer (); Tm. Interval= -; Tm. Enabled=true; TM. Elapsed + = new System.Timers.ElapsedEventHandler (tm_elapsed); Tm.            Start (); DT1=DateTime.Now; }        Private voidB2_click (Objectsender, EventArgs e) {TM. Enabled=false; DT2=DateTime.Now; MessageBox.Show (convert.tostring (DT2-dt1)); }        Private voidTm_elapsed (Objectsender, System.Timers.ElapsedEventHandler e) {lbmsg. Text= convert.tostring (+ +Number ); Thread.Sleep ( the); }    }}

When you edit the red line, you are prompted to do something wrong, so you can take a look at the official information of the software.

Back to the prototype of the function

 Public Delegate void elapsedeventhandler (    Object sender,    elapsedeventargs e)

So just put

        Private void tm_elapsed (objectSystem.Timers.ElapsedEventHandler e)        {            = convert.tostring (+ + number);            Thread.Sleep (+);        }

Change into

        Private void tm_elapsed (objectSystem.Timers.ElapsedEventArgs e)        {            = Convert.ToString (+ + number);            Thread.Sleep (+);        }

You can do it.

Troubleshooting: No multiple downloads are eligible for System.Timers.ElapsedEventHandler delegation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.