This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var subArray = new int[BUFFER_SIZE]; | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| Array.Copy(Data, i, subArray, 0, BUFFER_SIZE); | |
| if (subArray[subArray.Length - 1] != i + BUFFER_SIZE - 1) | |
| throw new Exception(); // avoid optimization | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var spanData = new Span<int>(Data); | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| var subSpan = spanData.Slice(i, BUFFER_SIZE); | |
| if (subSpan[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1) | |
| throw new Exception(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fixed (int* data = &Data[0]) | |
| { | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| int* sub = data + i; | |
| if (sub[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1) | |
| throw new Exception(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IntPtr pdata = Marshal.AllocHGlobal(Data.Length * sizeof(int)); | |
| int* data = (int*)pdata; | |
| try | |
| { | |
| Marshal.Copy(Data, 0, pdata, Data.Length); | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| int* sub = data + i; | |
| if (sub[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IAsyncObserver<in T> | |
| { | |
| Task OnNextAsync(T value); | |
| Task OnErrorAsync(Exception error); | |
| Task OnCompletedAsync(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Task<IAsyncDisposable> SubscribeAsync(IAsyncObserver<T> observer); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Reactive.Observable.Aliases; | |
| // filter will invoke where | |
| Observable.Range(0, 10).Filter(i => i % 2 == 0); | |
| Observable.Range(0, 10).Where(i => i % 2 == 0); | |
| // map will invoke select | |
| Observable.Range(0, 10).Map(i => $"- {i} -"); | |
| Observable.Range(0, 10).Select(i => $"- {i} -"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IObservable<TSource> Filter<TSource>( | |
| this IObservable<TSource> source, | |
| Func<TSource, bool> predicate) | |
| { | |
| return source.Where<TSource>(predicate); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static async Task Exec() | |
| { | |
| try | |
| { | |
| await Task.Delay(1); | |
| await A(); | |
| } | |
| catch (Exception ex) | |
| { | |
| Trace.WriteLine(ex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static async Task Exec() | |
| { | |
| try | |
| { | |
| await Task.Delay(1); | |
| await A(); | |
| } | |
| catch (Exception ex) | |
| { | |
| Trace.WriteLine(ex.Format()); |
OlderNewer