예제 #1
0
        public Task <IEnumerable <int> > GetFibonacciAsync(int n)
        {
            TaskCompletionSource <IEnumerable <int> > tcs = new TaskCompletionSource <IEnumerable <int> >();

            Task.Run(() =>
            {
                SampleFuncsWrapper.GetFibonacci(handle, n, (numberPtr, size) =>
                {
                    int[] numbersArray = new int[size];
                    Marshal.Copy(numberPtr, numbersArray, 0, size);

                    tcs.SetResult(new List <int>(numbersArray));
                });
            });

            return(tcs.Task);
        }
 public Task <IEnumerable <int> > GetFibonacciAsync(int n) => SampleFuncsWrapper.GetFibonacciAsync(handle, n);
예제 #3
0
 public SampleFuncs()
 {
     handle = SampleFuncsWrapper.CreateSampleFuncs();
 }
예제 #4
0
 protected override bool ReleaseHandle()
 {
     SampleFuncsWrapper.ReleaseSampleFuncs(this);
     return(true);
 }