473,378 Members | 1,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Threading related question

Shafi hashmi
hi dear..

i have to do the following program...

Expand|Select|Wrap|Line Numbers
  1. Label1.Text="Work Started..."
  2. Threading.Sleep(5000);
  3. Label1.Text="1st work finished. and next one started";
  4. Threading.Sleep(5000);
  5. Label1.Text="All work finished";
  6.  

i assume that this code should show the result.

"Work Started..."

after 5 second

"1st work finished. and next one started"

after 5 second

"All work finished"


NOOOOO but i get only last result "All work finished" and that too after 10 seconds


Why?? please help me?? i m in urgent

thank u in advance..
Jan 15 '11 #1
3 1062
Because your sleeps block your MAIN thread, therefor it will not execute till the last sleep is over.. but as u set it to another one (= all work finished) you wont notice the previous ones

hope this helped, but i'm pretty sure this is the problem
Jan 15 '11 #2
Ok. but if i want to do the same how its possible?
can u send me some example code??

thnx
Jan 15 '11 #3
hi friends i found the solutin something like this


Expand|Select|Wrap|Line Numbers
  1. Label1.Text="Work Started..."
  2.  Label1.Refresh();
  3.  Threading.Sleep(5000);
  4.  Label1.Text="1st work finished. and next one started";
  5.  Label1.Refresh();
  6.  Threading.Sleep(5000);
  7.  Label1.Text="All work finished";
  8.  Label1.Refresh();
  9.  
Jan 22 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andrew Gregory | last post by:
I've written a Tkinter application (Windows) that uses the threading module, which I've reduced to the test case below (apologies if it's a bit long). Using the Queue module to pass messages the...
3
by: bonj | last post by:
Hello How do I declare a template class such that the template class T must implement a certain interface? e.g. interface IProvideID { int MyID; };
5
by: Deiussum | last post by:
I'm running into an issue where I have a timer that appears to be timing out immediately, when it shouldn't be timing out for about int.MaxValue milliseconds. I have written a small app that...
2
by: JMax | last post by:
Hello! I have a question that I really can’t think of an answer for, but thought I might as well give a shot here. I have a web service, created by the VS web service creator. I have another...
5
by: microsoft | last post by:
Just researching threading and I'm sure we need to do more review of available resources BUT I'm wondering if what we're looking for is actually possible. If it is we can keep reading. I know...
0
by: archana | last post by:
Hi all, I have some confusion related to threading and autoresetevent. I have 5 threads running for each i have autoresetevent which i am setting through thread procedure. On each of event...
0
by: Alvin A. Delagon | last post by:
I have a multithreaded application that spawns threads which query a database server. During stress test I encountered some threads failing due "lost connection errors" and sometimes the actual...
2
by: Water Cooler v2 | last post by:
I want my application to do three tasks simultaneously. Each of the three tasks must be performed at a periodic interval of time. Each of the three tasks is somewhat complicated and is thus...
2
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I've two questions regarding the System.Threading.Thread namespace. First, what is the point of having a ThreadStart parameter? For example... using System.Threading;...
0
rsrinivasan
by: rsrinivasan | last post by:
Hi all, Where can i post Ant build related Question? Thanks,
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.