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);
public SampleFuncs() { handle = SampleFuncsWrapper.CreateSampleFuncs(); }
protected override bool ReleaseHandle() { SampleFuncsWrapper.ReleaseSampleFuncs(this); return(true); }