1 #Region "Microsoft.VisualBasic::e1e6a6f04a689ee9f6207a88f9a6ed52, Microsoft.VisualBasic.Core\ApplicationServices\Parallel\Threads\CodeThread.vb"
2
3     ' Author:
4     
5     '       asuka (amethyst.asuka@gcmodeller.org)
6     '       xie (genetics@smrucc.org)
7     '       xieguigang (xie.guigang@live.com)
8     
9     ' Copyright (c) 2018 GPL3 Licensed
10     
11     
12     ' GNU GENERAL PUBLIC LICENSE (GPL3)
13     
14     
15     ' This program is free software: you can redistribute it and/or modify
16     ' it under the terms of the GNU General Public License as published by
17     ' the Free Software Foundation, either version 3 of the License, or
18     ' (at your option) any later version.
19     
20     ' This program is distributed in the hope that it will be useful,
21     ' but WITHOUT ANY WARRANTY; without even the implied warranty of
22     ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     ' GNU General Public License for more details.
24     
25     ' You should have received a copy of the GNU General Public License
26     ' along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28
29
30     ' /********************************************************************************/
31
32     ' Summaries:
33
34     '     Class CodeThread
35     
36     '         Constructor: (+1 OverloadsSub New
37     
38     '         FunctionGetThread
39     
40     '         Sub: [Resume], Pause, Run
41     
42     
43     ' /********************************************************************************/
44
45 #End Region
46
47 Imports System.Threading
48 Imports Microsoft.VisualBasic.Language
49
50 Namespace Parallel.Threads
51
52     Public MustInherit Class CodeThread : Inherits BaseClass
53
54         Protected ReadOnly __thread As Thread
55
56         Sub New()
57             __thread = New Thread(AddressOf __run)
58         End Sub
59
60         Protected MustOverride Sub __run()
61
62         Public Shared Function GetThread(x As CodeThread) As Thread
63             Return x.__thread
64         End Function
65
66         Public Shared Sub Run(x As CodeThread)
67             Call x.__thread.Start()
68         End Sub
69
70         Public Shared Sub Pause(x As CodeThread)
71 #Disable Warning
72             Call x.__thread.Suspend()
73 #Enable Warning
74         End Sub
75
76         Public Shared Sub [Resume](x As CodeThread)
77 #Disable Warning
78             Call x.__thread.Resume()
79 #Enable Warning
80         End Sub
81     End Class
82 End Namespace