[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

System.Windows.Forms.Timer GetBoardTypeConnected;

Posted on 2009-02-16
2
Medium Priority
?
247 Views
Last Modified: 2013-12-17
Hello,

I  have problems with the following code.
I wanted to enter the "GetBoardTypeFunc" only once, therefore in this function I stop the timer.
Although I stopped the timer I see that I continue to enter the "GetBoardTypeFunc" function.
Why?
Should I unsubscribe from the event EventHandler(GetBoardTypeFunc)?
If yes, what is a sintax?

THANKS
Margarit
System.Windows.Forms.Timer GetBoardTypeConnected;
//////////////////////////////////////////////////////////////////////////////////////////////////////
private void GetBoardType()
        {
            GetBoardTypeConnected = new System.Windows.Forms.Timer();
            GetBoardTypeConnected.Interval = 400;// 250;
            GetBoardTypeConnected.Start();
            GetBoardTypeConnected.Tick += new EventHandler(GetBoardTypeFunc);
        }
 
 private void GetBoardTypeFunc(Object state, EventArgs eArgs)
        {
            a++;
            GetBoardTypeConnected.Stop();
            GetBoardTypeConnected.Dispose();
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////

Open in new window

0
Comment
Question by:margarit
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 23661090
My guess is that you are calling GetBoardType() more than once...what triggers a call to that sub?

Pop a MessageBox in there and see if that is what's happening:


        private void GetBoardType()
        {
            MessageBox.Show("Entering GetBoardType()...");
            GetBoardTypeConnected = new System.Windows.Forms.Timer();
            GetBoardTypeConnected.Interval = 400;// 250;
            GetBoardTypeConnected.Start();
            GetBoardTypeConnected.Tick += new EventHandler(GetBoardTypeFunc);
        }

Open in new window

0
 

Author Closing Comment

by:margarit
ID: 31547666
Thanks! The solution worked for me. This function was called more than once from another event.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month18 days, 16 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question