|
26 | 26 |
|
27 | 27 | using ObjCRuntime;
|
28 | 28 |
|
| 29 | +#nullable enable |
| 30 | + |
29 | 31 | namespace Foundation {
|
30 | 32 |
|
31 | 33 | public partial class NSThread {
|
32 |
| - |
33 |
| - /// <summary>To be added.</summary> |
34 |
| - /// <value>To be added.</value> |
35 |
| - /// <remarks>To be added.</remarks> |
| 34 | + /// <summary>Get or set the current thread's priority.</summary> |
| 35 | + /// <value>The current thread's priority, between 0.0 (lowest priority) and 1.0 (highest priority).</value> |
36 | 36 | public static double Priority {
|
37 | 37 | get { return _GetPriority (); }
|
38 | 38 | // ignore the boolean return value
|
39 | 39 | set { _SetPriority (value); }
|
40 | 40 | }
|
41 | 41 |
|
42 | 42 | [DllImport ("__Internal")]
|
43 |
| - static extern IntPtr xamarin_init_nsthread (IntPtr handle, byte is_direct_binding, IntPtr target, IntPtr selector, IntPtr argument); |
| 43 | + static extern NativeHandle xamarin_init_nsthread (IntPtr handle, byte is_direct_binding, IntPtr target, IntPtr selector, IntPtr argument); |
44 | 44 |
|
45 |
| - IntPtr InitNSThread (NSObject target, Selector selector, NSObject argument) |
| 45 | + NativeHandle InitNSThread (NSObject target, Selector selector, NSObject? argument) |
46 | 46 | {
|
47 | 47 | if (target is null)
|
48 |
| - throw new ArgumentNullException ("target"); |
| 48 | + ThrowHelper.ThrowArgumentNullException (nameof (target)); |
49 | 49 | if (selector is null)
|
50 |
| - throw new ArgumentNullException ("selector"); |
| 50 | + ThrowHelper.ThrowArgumentNullException (nameof (selector)); |
51 | 51 |
|
52 |
| - IntPtr result = xamarin_init_nsthread (IsDirectBinding ? this.Handle : this.SuperHandle, IsDirectBinding.AsByte (), target.Handle, selector.Handle, argument is null ? IntPtr.Zero : argument.Handle); |
| 52 | + IntPtr result = xamarin_init_nsthread (IsDirectBinding ? this.Handle : this.SuperHandle, IsDirectBinding.AsByte (), target.Handle, selector.Handle, argument.GetHandle ()); |
53 | 53 | GC.KeepAlive (target);
|
54 | 54 | GC.KeepAlive (selector);
|
55 | 55 | GC.KeepAlive (argument);
|
56 | 56 | return result;
|
57 | 57 | }
|
58 | 58 |
|
| 59 | + /// <summary>Create a new thread.</summary> |
| 60 | + /// <param name="target">The object with the method to execute on the new thread.</param> |
| 61 | + /// <param name="selector">The selector that specifies the method to execute on the new thread.</param> |
| 62 | + /// <param name="argument">The argument to pass to the method to execute on the new thread.</param> |
59 | 63 | [Export ("initWithTarget:selector:object:")]
|
60 |
| - public NSThread (NSObject target, Selector selector, NSObject argument) |
61 |
| - : base () |
| 64 | + public NSThread (NSObject target, Selector selector, NSObject? argument) |
| 65 | + : base (NSObjectFlag.Empty) |
62 | 66 | {
|
63 |
| - Handle = InitNSThread (target, selector, argument); |
| 67 | + InitializeHandle (InitNSThread (target, selector, argument), "initWithTarget:selector:object:"); |
64 | 68 | }
|
65 | 69 | }
|
66 | 70 | }
|
0 commit comments