Ejemplo n.º 1
0
        protected PromiseBase(PromiseCreateOptions createOptions, CancellationToken cancellationToken)
        {
            PromiseSafeHandle promiseSafeHandle = null;
            int result = -1;

            try
            {
                result = NativeLibrary.ApiGenPromiseCreate(ref createOptions, out promiseSafeHandle);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, $"NativeLibrary.ApiGenPromiseCreate threw exception {ex.Message}");
            }

            if (result != 0)
            {
                throw new InvalidOperationException();
            }

            this.Handle        = promiseSafeHandle;
            this.createOptions = createOptions;
            this.cancellationTokenRegistration = cancellationToken.Register(() => NativeLibrary.ApiGenPromiseCancel(promiseSafeHandle));
        }
 public extern static int ApiGenPromiseCancel(PromiseSafeHandle promiseHandle);
 public extern static int ApiGenPromiseCreate(ref PromiseCreateOptions options, out PromiseSafeHandle promiseHandle);