-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThread.cs
More file actions
80 lines (70 loc) · 2.15 KB
/
Thread.cs
File metadata and controls
80 lines (70 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
namespace PCLExt.Thread
{
/// <summary>
///
/// </summary>
public static class Thread
{
private static Exception NotImplementedInReferenceAssembly() =>
new NotImplementedException(@"This functionality is not implemented in the portable version of this assembly.
You should reference the PCLExt.Thread NuGet package from your main application project in order to reference the platform-specific implementation.");
/// <summary>
///
/// </summary>
public static int Threads
{
get
{
#if DESKTOP || ANDROID || __IOS__ || MAC
return System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
#endif
throw NotImplementedInReferenceAssembly();
}
}
/// <summary>
///
/// </summary>
/// <param name="start"></param>
/// <returns></returns>
public static IThread Create(ThreadStart start)
{
#if DESKTOP || ANDROID || __IOS__ || MAC
return new DesktopThread(start);
#endif
throw NotImplementedInReferenceAssembly();
}
/// <summary>
///
/// </summary>
/// <param name="start"></param>
/// <returns></returns>
public static IThread Create(ParameterizedThreadStart start)
{
#if DESKTOP || ANDROID || __IOS__ || MAC
return new DesktopThread(start);
#endif
throw NotImplementedInReferenceAssembly();
}
/// <summary>
///
/// </summary>
/// <param name="milliseconds"></param>
public static void Sleep(int milliseconds)
{
#if DESKTOP || ANDROID || __IOS__ || MAC
System.Threading.Thread.Sleep(milliseconds);
#endif
}
/// <summary>
///
/// </summary>
/// <param name="waitCallback"></param>
public static void QueueUserWorkItem(WaitCallback waitCallback)
{
#if DESKTOP || ANDROID || __IOS__ || MAC
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(waitCallback));
#endif
}
}
}