private Timer Clock = new Timer();//create a timer
void Clock_Tick(object sender, EventArgs e)
//refresh the time every 1 second
this.winFormTimerLabel.Text = DateTime.Now.ToLongTimeString();
private void Form1_Load(object sender, EventArgs e)
Clock.Interval = 1000;//every 1 second do something
//what the program is supposed to do when 1 second elasped
Clock.Tick += new EventHandler(Clock_Tick);
Clock.Start();//starts the timer
I finally understood where did I went wrong - I did not put in the interval value and I did not start the timer..... silly me
Ok when i created a new Query, they asked me Type of SQL query to use.
SELECT which return rows
SELECT which return single value
At first, i selected "SELECT which return rows" and they asked for 3 arguement. dataTable, string nric and string password.
So i change to "SELECT which return single value"
string result = sa.ValidateLogin(txtUsername.Text, txtPassword.Text);
When i key the correct username and password, the messagebox shows the username. If i enter a wrong username and password, the whole program ended and point to my code and says, NullReferenceException was unhandled.
If the correct username was found, i want to store the results of other columm to my variable i declared. Because my staff table have
i have an application that work with threading.
in load_form event of the form i create an instance a thread object and run it,
now my problem is , i want to kill the thread on another event such as button_click event on this form and i cant do it.
i can not create my thread public, because the number of thread should be create is not certain in my allpication,
how can i do it, please sya me a solution to solve it...
nobody help you...
you have to help you yourself
and this is success way.
The only reliable way to kill a thread is to let the thread terminate normally.
This means you need a way to notify a thread that it needs to terminate, and
provide a way to wait for the thread to terminate if necessary.
There's synchronization objects you can use. For example, EventWaitHandle.
There's no need to "create my thread public", but you may need to keep contexts
to your created threads somewhere, like in a collection in your form class.
Microsoft MVP - Visual C++
Last Visit: 28-Oct-20 16:24 Last Update: 28-Oct-20 16:24