1
00:00:00,660 --> 00:00:01,720
Hello, welcome back.

2
00:00:01,740 --> 00:00:07,020
In this lesson, we're going to see how to suspend a task, so I'm going to make a copy of this last

3
00:00:07,020 --> 00:00:07,560
project.

4
00:00:08,570 --> 00:00:17,120
Copy and then paste over here, and then I'm going to call this number eight, suspending the task.

5
00:00:27,750 --> 00:00:28,710
And I'm going to open it.

6
00:00:36,810 --> 00:00:37,290
OK.

7
00:00:38,310 --> 00:00:40,150
So let's get started.

8
00:00:40,620 --> 00:00:46,440
We're going to start off by having all of the tasks created with the same priority level, so I'm going

9
00:00:46,440 --> 00:00:51,780
to change the priority of blue over here to one such that they all have the same priority.

10
00:00:52,320 --> 00:00:56,050
And then over here we did get priority.

11
00:00:56,070 --> 00:00:56,970
I'm going to delete this.

12
00:00:56,970 --> 00:00:58,280
We don't need this for this project.

13
00:00:58,290 --> 00:01:00,000
We need such priority of blue.

14
00:01:00,020 --> 00:01:00,930
I'm going to delete this.

15
00:01:01,260 --> 00:01:04,830
So it looks like our task creation version.

16
00:01:05,610 --> 00:01:07,050
We've created three tasks.

17
00:01:07,260 --> 00:01:09,030
They all have priority of one.

18
00:01:09,390 --> 00:01:11,120
And here are the task functions.

19
00:01:11,520 --> 00:01:13,560
What I'm going to do is I'm going to make.

20
00:01:15,100 --> 00:01:16,030
I'm going to make.

21
00:01:17,220 --> 00:01:26,190
The red task suspend the blue task after a number of iterations and when I put a counter variable here

22
00:01:27,210 --> 00:01:34,530
over here of great, you ain't 32 unaskable to which I shall call to suspend, which, of course, suspend,

23
00:01:34,530 --> 00:01:41,090
monitor and assure the account that they would monitor when we should suspend just to demonstrate how

24
00:01:41,100 --> 00:01:42,120
suspension works.

25
00:01:42,690 --> 00:01:43,680
So come over here.

26
00:01:46,010 --> 00:01:53,090
What I'm going to do is I'm going to add a bit of delay to each of our profilers, otherwise this is

27
00:01:53,090 --> 00:01:56,060
just going to move very fast.

28
00:01:56,930 --> 00:01:59,600
So I'll create a local rainbow over here.

29
00:02:00,720 --> 00:02:07,160
Then I'll say four equals zero is less than.

30
00:02:08,770 --> 00:02:17,190
Let's see, a hundred thousand I plus plus, okay, I'm going to do the same for the others.

31
00:02:20,130 --> 00:02:23,430
Over here as well, then I'll copy this.

32
00:02:25,940 --> 00:02:28,690
Then over here, the local is yeah.

33
00:02:29,170 --> 00:02:30,630
OK, so here we are.

34
00:02:32,730 --> 00:02:36,900
What I'm going to do is, like we said in red, we're going to suspend.

35
00:02:37,970 --> 00:02:38,960
We're going to suspend.

36
00:02:41,950 --> 00:02:47,550
We're going to suspend Lisa Bloom, so whenever Red executes, I'm going to incrementalists or spend

37
00:02:47,570 --> 00:02:49,330
money to assess or spend money to.

38
00:02:49,360 --> 00:02:50,080
Plus, plus.

39
00:02:50,950 --> 00:02:51,440
Okay.

40
00:02:52,240 --> 00:02:57,990
And then I'm going to see if suspend monitor.

41
00:02:59,980 --> 00:03:01,020
It's just been monitored.

42
00:03:01,030 --> 00:03:03,460
Alesi is greater than.

43
00:03:05,200 --> 00:03:11,890
Or equal to 50, then we would we would invoke a piece of code.

44
00:03:14,880 --> 00:03:19,080
Or invoke this function v task, suspend.

45
00:03:19,110 --> 00:03:21,960
This is the function for suspending the task.

46
00:03:22,500 --> 00:03:25,240
All we have to do is pass the task function here.

47
00:03:26,310 --> 00:03:29,100
The task Hondo sorry, arguments.

48
00:03:31,690 --> 00:03:34,880
OK, so let's see how that works.

49
00:03:35,350 --> 00:03:42,850
The reason I'm using suspend Monitise, if we simply call V task suspend, then we would see that before

50
00:03:42,850 --> 00:03:44,540
and after suspension changes.

51
00:03:44,860 --> 00:03:51,550
So what we would see is actually we would see that all task will be running and then after a while would

52
00:03:51,550 --> 00:03:52,220
stop running.

53
00:03:52,740 --> 00:03:54,580
OK, I'll click here to view it.

54
00:03:59,260 --> 00:03:59,810
Luca.

55
00:04:01,610 --> 00:04:04,640
There's so little money here to build.

56
00:04:07,620 --> 00:04:08,740
People successfully.

57
00:04:09,810 --> 00:04:11,220
Quickly, let's get onto the board.

58
00:04:12,870 --> 00:04:13,530
But eight.

59
00:04:15,380 --> 00:04:16,030
OK.

60
00:04:21,090 --> 00:04:21,480
Which.

61
00:04:23,240 --> 00:04:24,970
So I'm going to come over here.

62
00:04:27,170 --> 00:04:32,790
And I'm going to spend money to watch winter, where I spend money to controversy.

63
00:04:34,570 --> 00:04:43,600
Ed, over here, then I'm going to click to run or iterate and suspend monitors currently 17, 18,

64
00:04:43,600 --> 00:04:44,170
19.

65
00:04:44,440 --> 00:04:46,810
I see, I see they're all going.

66
00:04:48,030 --> 00:04:50,560
They are all iterates, and that's almost the same rate.

67
00:04:51,730 --> 00:05:00,280
OK, you see where I spend money to pass 50 blue stopped moving, now we just have red and green moving.

68
00:05:00,490 --> 00:05:03,650
So blue has been suspended, right?

69
00:05:04,000 --> 00:05:05,620
So that is how we suspend a task.

70
00:05:06,250 --> 00:05:07,410
So we suspend the task.

71
00:05:07,900 --> 00:05:08,270
Right.

72
00:05:09,160 --> 00:05:15,790
So I'm going to create another project or what I'm going to do is actually I'll leave this to you as

73
00:05:15,820 --> 00:05:16,500
assignment.

74
00:05:17,020 --> 00:05:24,520
So I, I want you to create a function or create a project in which the task suspends itself.

75
00:05:25,940 --> 00:05:32,540
Remember, we saw that we said if you want to suspend a task, if you undertook the task to suspend

76
00:05:32,540 --> 00:05:37,180
itself, you can either pass now or the task Hondo as the argument.

77
00:05:37,730 --> 00:05:44,900
So I want you to to run the experiment and make sure it works just like we saw for the set priority

78
00:05:44,900 --> 00:05:45,390
function.

79
00:05:45,950 --> 00:05:46,430
OK.

80
00:05:48,020 --> 00:05:48,440
Right.

81
00:05:49,040 --> 00:05:55,550
So in the next lesson, we're going to see how to resume the task, we've seen how to suspend a task

82
00:05:55,550 --> 00:05:58,870
here, we would have to find ways to resume them when we suspend him.

83
00:05:59,390 --> 00:06:01,460
So I'll see you in the next lesson of a nice.
