Click here to Skip to main content
15,909,953 members
Home / Discussions / C#
   

C#

 
Questiondyanamically adding labels to panel Pin
Ram Kiran1-Nov-06 5:23
Ram Kiran1-Nov-06 5:23 
AnswerRe: dyanamically adding labels to panel Pin
sam#1-Nov-06 6:42
sam#1-Nov-06 6:42 
GeneralRe: dyanamically adding labels to panel Pin
Ram Kiran1-Nov-06 21:34
Ram Kiran1-Nov-06 21:34 
QuestionHow can I wait for a given seconds without blocking. Pin
Nadia Monalisa1-Nov-06 5:13
Nadia Monalisa1-Nov-06 5:13 
AnswerRe: How can I wait for a given seconds without blocking. Pin
led mike1-Nov-06 5:18
led mike1-Nov-06 5:18 
GeneralRe: How can I wait for a given seconds without blocking. Pin
Nadia Monalisa1-Nov-06 7:17
Nadia Monalisa1-Nov-06 7:17 
AnswerRe: How can I wait for a given seconds without blocking. Pin
mav.northwind1-Nov-06 6:48
mav.northwind1-Nov-06 6:48 
GeneralRe: How can I wait for a given seconds without blocking. Pin
Nadia Monalisa1-Nov-06 7:13
Nadia Monalisa1-Nov-06 7:13 
Hello,
Thanks for your reply.

Actually my purpose is not to trigger timed event. Ok, just consider the following code,

private void doNothing_Important()
{
int a = 5;
int b = 6;
int c = a + b;
Thread.Sleep(2000);
b = c - 1;
}

Now, in my that code, I want to wait for 2 seconds before executing the last line but If I use Thread.Sleep(2000), then all user interface controls are blocked. An alternative way to perform this task without blocking is to use a thread or backgroudnworker. I can call the Background worker Asynchronously and make a while loop to check if the thread is completed. like this,

private void doNothing_Important()
{
int a = 5;
int b = 6;
int c = a + b;

backGroundWorker1.runWorkerAsyncrhonous();
while(backGroundWorker1.IsBusy)
Application.DoEvents();

b = c - 1;
}

backGroundWorker1_DoWork(BWEventargs e.....)
{
Thread.Sleep(2000);
}


Now, My question is, IS there any other better short cut way to perform the same sleeping task ?

Regards
emran
GeneralRe: How can I wait for a given seconds without blocking. Pin
mav.northwind1-Nov-06 18:51
mav.northwind1-Nov-06 18:51 
GeneralRe: How can I wait for a given seconds without blocking. Pin
[Marc]2-Nov-06 1:25
[Marc]2-Nov-06 1:25 
GeneralRe: How can I wait for a given seconds without blocking. Pin
Nadia Monalisa2-Nov-06 5:55
Nadia Monalisa2-Nov-06 5:55 
GeneralRe: How can I wait for a given seconds without blocking. Pin
[Marc]2-Nov-06 11:28
[Marc]2-Nov-06 11:28 
GeneralRe: How can I wait for a given seconds without blocking. Pin
Nadia Monalisa2-Nov-06 11:59
Nadia Monalisa2-Nov-06 11:59 
GeneralRe: How can I wait for a given seconds without blocking. Pin
[Marc]2-Nov-06 12:17
[Marc]2-Nov-06 12:17 
QuestionAccessing data from a class in main form(program) Pin
dkoco1-Nov-06 4:04
dkoco1-Nov-06 4:04 
AnswerRe: Accessing data from a class in main form(program) Pin
dkoco1-Nov-06 4:50
dkoco1-Nov-06 4:50 
Questionchange size of textbox at runtime Pin
Ajay R Ojha1-Nov-06 3:24
Ajay R Ojha1-Nov-06 3:24 
AnswerRe: change size of textbox at runtime Pin
Colin Angus Mackay1-Nov-06 4:22
Colin Angus Mackay1-Nov-06 4:22 
GeneralRe: change size of textbox at runtime Pin
Ajay R Ojha1-Nov-06 17:31
Ajay R Ojha1-Nov-06 17:31 
AnswerRe: change size of textbox at runtime Pin
Rahithi3-Nov-06 7:37
Rahithi3-Nov-06 7:37 
QuestionForcing single processor mode Pin
Bekjong1-Nov-06 3:02
Bekjong1-Nov-06 3:02 
AnswerRe: Forcing single processor mode Pin
Dan Neely1-Nov-06 3:18
Dan Neely1-Nov-06 3:18 
GeneralRe: Forcing single processor mode Pin
Bekjong1-Nov-06 3:26
Bekjong1-Nov-06 3:26 
GeneralRe: Forcing single processor mode Pin
mav.northwind1-Nov-06 4:11
mav.northwind1-Nov-06 4:11 
GeneralRe: Forcing single processor mode Pin
Bekjong1-Nov-06 4:48
Bekjong1-Nov-06 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.