mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-04-05 17:37:51 +08:00
41 lines
684 B
C#
41 lines
684 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace CPF.Mac.Foundation
|
|
{
|
|
[Register("__MonoMac_NSAsyncActionDispatcher")]
|
|
internal class NSAsyncActionDispatcher : NSObject
|
|
{
|
|
private GCHandle gch;
|
|
|
|
private NSAction action;
|
|
|
|
[Obsolete("Do not use, this method is only used internally")]
|
|
public NSAsyncActionDispatcher(IntPtr handle)
|
|
: base(handle)
|
|
{
|
|
}
|
|
|
|
public NSAsyncActionDispatcher(NSAction action)
|
|
{
|
|
this.action = action;
|
|
gch = GCHandle.Alloc(this);
|
|
}
|
|
|
|
[Export("xamarinApplySelector")]
|
|
[Preserve(Conditional = true)]
|
|
public void Apply()
|
|
{
|
|
try
|
|
{
|
|
action();
|
|
}
|
|
finally
|
|
{
|
|
action = null;
|
|
gch.Free();
|
|
}
|
|
}
|
|
}
|
|
}
|