@@ -106,25 +106,27 @@ To begin this tutorial, you need a multithreaded application project. Follow the
106
106
#include <iostream>
107
107
#include <vector>
108
108
109
+ using namespace ;
110
+
109
111
int count = 0 ;
110
112
111
113
void doSomeWork () {
112
114
113
- std :: cout << " The doSomeWork function is running on another thread." << std :: endl ;
115
+ cout << " The doSomeWork function is running on another thread." << endl ;
114
116
int data = count ++ ;
115
117
// Pause for a moment to provide a delay to make
116
118
// threads more apparent.
117
- std :: this_thread :: sleep_for (std : : chrono :: seconds (3 ));
118
- std :: cout << " The function called by the worker thread has ended." << std :: endl ;
119
+ this_thread :: sleep_for (chrono :: seconds (3 ));
120
+ cout << " The function called by the worker thread has ended." << endl ;
119
121
}
120
122
121
123
int main () {
122
- std :: vector < std :: thread > threads ;
124
+ vector < thread > threads ;
123
125
124
126
for (int i = 0 ; i < 10 ; ++ i ) {
125
127
126
- threads .push_back (std : : thread (doSomeWork ));
127
- std :: cout << " The Main() thread calls this after starting the new thread" << std :: endl ;
128
+ threads .push_back (thread (doSomeWork ));
129
+ cout << " The Main() thread calls this after starting the new thread" << endl ;
128
130
}
129
131
130
132
for (auto & thread : threads ) {
@@ -198,17 +200,18 @@ To begin this tutorial, you need a multithreaded application project. Follow the
198
200
```
199
201
200
202
```C ++
201
- Thread :: Sleep ( 3000 );
202
- Console . WriteLine ();
203
+ this_thread :: sleep_for ( chrono : : seconds ( 3 ));
204
+ cout << " The function called by the worker thread has ended. " << endl ;
203
205
```
206
+
204
207
```VB
205
208
Thread .Sleep (3000 )
206
209
Console .WriteLine ()
207
210
```
208
211
209
212
#### To start debugging
210
213
211
- 1 . Click in the left gutter of the `Thread .Sleep ` or `Thread :: Sleep ` statement to insert a new breakpoint .
214
+ 1 . Click in the left gutter of the `Thread .Sleep ` or `this_thread :: sleep_for ` statement to insert a new breakpoint .
212
215
213
216
In the gutter on the left side of the source code editor , a red circle appears . This indicates that a breakpoint is now set at this location .
214
217
@@ -226,7 +229,7 @@ To begin this tutorial, you need a multithreaded application project. Follow the
226
229
```
227
230
228
231
```C++
229
- Thread::Sleep( 3000 );
232
+ this_thread::sleep_for( chrono :: seconds ( 3 ));
230
233
```
231
234
232
235
```VB
@@ -255,7 +258,7 @@ In the **Parallel Stacks** window, you can switch between a Threads view and (fo
255
258
256
259

257
260
258
- In this example, from left to right we get this information:
261
+ In this example, from left to right we get this information for managed code :
259
262
260
263
- The Main thread (left side ) has stopped on `Thread.Start` (the stop point is indicated by the thread marker icon ).
261
264
- Two threads have entered the `ServerClass.InstanceMethod`, one of which is the current thread (yellow arrow ), while the other thread has stopped in `Thread.Sleep`.
0 commit comments