<< (back to Task) My multithreading learning conspectus << (back to QuickHelp)
- 1. APM (Asynchronous Programming Model).
- 2. EAP (Event-based Asynchronous Pattern).
- 3. TAP (Task-based Asynchronous Pattern).
- 4. Ms documentation about Task and Thread.
- 5. Threading and Task synchronization.
- 6. BackgroundWorker.
- 7. Parallel library.
- 8. Reactive NET extension
- 9. MultiThreading in NET Core 6.
- 10. Delegate Task vs Promise Task (.NET).
- 11. .NET Promise task is the same than Promise in JS.
- 12. Delegate Task vs Promise Task Article.
- 13. Task Yield.
- 14. Other point of view
1. APM (Asynchronous Programming Model).
Working since NET 1.1 and currently not implemented in .NET CORE, run synchronously.
Contains BeginRead/EndRead, IsyncResult interface, State object with IsComplete flag.
Common scheme:
Dim RequestState As New With { ...} Sub Task() Dim Request As Net.HttpWebRequest = Net.HttpWebRequest.Create("") Dim Res As IAsyncResult = CType(Request.BeginGetResponse(New AsyncCallback(AddressOf RespCallback), RequestState), IAsyncResult) End Sub Sub RespCallback(ByVal ar As IAsyncResult) End Sub
Examples on my site.
- My web scrapper with asynchronous web request and visual proxy availability detection.
- EventLogger - example of Task.Factory.FromAsync, Task.Run, ReaderWriterLock, Interlocked.Increment, Stream.BeginWrite, SyncLock, Timeout, AsyncCallback, IAsyncResult, String.Format, Timespan.
Full documentation. Asynchronous Programming Model.pdf
2. EAP (Event-based Asynchronous Pattern).
Require method with ___Async suffix, require Event and EventHandler and EventArgs as derived type. You can provide own private delegate, own derived handler from EventHandler, and can provide own StateObject, own Cancel method. Support IProgress and ReadComplete event.
Async Function ExecuteAsync(ByVal SshCommand As SshCommand, ByVal OutputLine As IProgress(Of SshOutputLine), ByVal CTX As CancellationToken) As Task
Examples on my site.
- RichTextBox1.AppendColorTextAsync - Multi Languages Spell Checker for webmaster. Part 5. Multilang asynchronous spell checker with NHunspell.
- FillGridAsync - (EF DB First and ADO NET Typed Dataset, Tree ways to Binding GridView and ComboBox, Set Timeout, Asynchronous fill table by data)
- Part 1,2 (Database and SSH client). StreamReader/ReadToEndAsync, Extension/Inherits/Overloads, BeginExecute/EndExecute/IAsyncResult/IProgress(Of T)/Async/Await/CancellationToken/Task.Run/Thread.Yield.
Full documentation. Event-based Asynchronous Pattern.pdf
3. TAP (Task-based Asynchronous Pattern).
Future.
- Exception stored on StateObject
- Return Task(of TResult). Any complex parameters you want to rerurn you should return as tuples.
- ContinueWith - waiting result by Task class OR Await as language future. Also support ContinueWhenAll/ContinueWhenAny.
- Support interface IProgress and CancelationTokenSource.Token
- TaskFactory.StartNew (Action (Of T)) or (Function(of TResult) Return Task (Tresult))
- Since NET 4.5 TaskFactory.StartNew has shortcut Task.Run
Await ReadAsync(Nothing, Nothing, Nothing) Async Function ReadAsync(Buf, offset, count) As Task(Of Int16) End Function
Examples on my site.
- Monitoring docker events
- Part 7,8 (QuartzService/Jobs and Singleton CacheService). ConcurrentDictionary, Interlocked.Increment, SyncLock, Closure variable for MultiThreading, Cron Configuration.
- ASP.NET Core BackEnd with MailKit/IMAP (Async/Await, Monitor, ConcurrentQueue, CancellationTokenSource)
Full documentation.
4. Ms documentation about Task and Thread.
5. Threading and Task synchronization.
Future.
- DOP - Decrease of parallelism
Full documentation.
6. BackgroundWorker.
Examples on my site.
- Multithreading Parsers with Parallel, CsQuery, Newtonsoft.Json, OfficeOpenXml and IAsyncResult/AsyncCallback.
- Multi Languages Spell Checker for webmaster. Part 5. Multilang asynchronous spell checker with NHunspell.
- BackgroundWorkerQueue.
Full documentation. Event-based Asynchronous Pattern.pdf
7. Parallel library.
Examples on my site.
Full documentation. Parallel Programming.pdf
8. Reactive NET extension.
Examples on my site.
9. MultiThreading in NET Core 6.
Future.
- Support Environment.ProcessorCount
- APM working synchronously, not supported.
- Parallel.ForEach working synchronously, not supported. Has replacement to Parallel.ForEachAsync.
- Return ValueTask instead Task (Task (of T) return Nothing, if task call synchronously, but ValueTask return event even task run synchronously.
- new operation with CancelationTokinSource - ctx.TryReset.
- Thread.ManagedThreadID and Thread.UnsafeStart- not supported
10. Delegate Task vs Promise Task (.NET).
11. .NET Promise task is the same than Promise in JS.
12. Delegate Task vs Promise Task Article.Read more about difference...
Article contains description of:
- Wait/WaitAll/WaitAny
- GetAwaiter().GetResult()/await
- ContinueWith/TaskFactory.ContinueWhenAny/TaskFactory.ContinueWhenAll/Task.WhenAll/Task.WhenAny
In the TPL world the various Delegate Tasks are divided up among different threads, which then actually execute the code in those Delegate Tasks. Read more
- TaskFactory.StartNew
- CancellationToken
- TaskCreationOptions
- TaskScheduler
- Task.Run (shortcut of Task.Factory.StartNew)
In the async world, most tasks are Promise Tasks. When code does an await on a Promise Task, there is no thread tied up waiting for that task to complete. read more No thread mean there is only kernel callback.
- Task.Delay
- Task.Yield
- Task.FromResult replaced to Task.CompletedTask since NET 4.6
How to correct select type of multiThreading.
12. Task Yield.
- My own code - Asynchronous MultiThreaded SSH engine for Web (Net Core 6, Linux) - Part 1,2 (Database and SSH client). StreamReader/ReadToEndAsync, Extension/Inherits/Overloads, BeginExecute/EndExecute/IAsyncResult/IProgress(Of T)/Async/Await/CancellationToken/Task.Run/Thread.Yield.
- Task.Yield - real usages
14. Other point of view read more ....
<SITEMAP> <MVC> <ASP> <NET> <DATA> <KIOSK> <FLEX> <SQL> <NOTES> <LINUX> <MONO> <FREEWARE> <DOCS> <ENG> <CHAT ME> <ABOUT ME> < THANKS ME> |