Click here to Skip to main content
11,642,216 members (61,206 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 Threading
I have created thread as
    Thread th = new Thread(DoSomething);
        th.IsBackground = true;
but th.sleep(); not working
but at the same time main thread
System.Threading.Thread.Sleep(1000);
working fine
Please suggest
Posted 26-Nov-11 18:43pm
Edited 26-Nov-11 21:33pm
thatraja246.2K
v3
Comments
Mark Nischalke at 27-Nov-11 0:49am
   
I suugest you properly format you question, use pre tags around code, not use txt speak and not shout, don't use all caps

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

"Not working" means: it won't compile. That's correct.

The method System.Threading.Thread.Sleep is static. You don't need a thread reference to indicate what thread should be effected: the thread to be put to sleep is the current thread. In this way, a code thread can put to sleep only the same thread running this code. This is a common paradigm of all threaded systems.

—SA
  Permalink  
Comments
Mehdi Gholam at 27-Nov-11 2:09am
   
5'ed
SAKryukov at 27-Nov-11 11:56am
   
Thank you, Mehdi.
--SA
Eduard Lu at 27-Nov-11 4:12am
   
agree
SAKryukov at 30-Nov-11 20:20pm
   
Good. Thank you, Eduard.
--SA
Amol_Joshi at 27-Nov-11 9:37am
   
TRUE
SAKryukov at 30-Nov-11 20:21pm
   
Sure. Thank you, Amol.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 240
1 Sergey Alexandrovich Kryukov 184
2 Afzaal Ahmad Zeeshan 139
3 OriginalGriff 135
4 Mika Wendelius 80
0 Mika Wendelius 460
1 DamithSL 443
2 OriginalGriff 340
3 Afzaal Ahmad Zeeshan 228
4 Sergey Alexandrovich Kryukov 179


Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 27 Nov 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100