There are several patterns to call a synchronous method asynchronously as shown below.
1- BeginInvoke and EndInvoke
BeginInvoke and EndInvoke Pattern
As you see that first message written in console is worked in main thread (ThreadID is 1), But, DoWork() method is called asynchronously, so that, second message is worked on different thread (ThreadID is 3).
DoWork() method returns int value and without parameters, so that, BeginInvoke method shows two parameters(callback, @object) as shown in Figure-2
Notice that EndInvoke() method takes asyncResult variable returned by BeginInvoke() method and it also returns int value because of Func delegate in Figure-3.
The following example demonstrate how to copy files from TcpClient to TcpListener on network asycnhronously. While copying files asynchronously, percentage of copied files are also updated asynchronously.
if cancellation is needed, application can be cancelled by Ctrl + c keys.
The following example demonstrate how to copy files from one directory to other directory asycnhronously. While copying files asynchronously, percentage of copied files are also updated asynchronously.
Notice the second picture, Total files count is 20. But, application could copy 17 files. Because, another process has been using those 3 files. I think you can solve this problem 🙂
if cancellation is needed, application can be cancelled by Ctrl + c keys. It is shown in the third picture.
UniSchedule is a very fast job scheduler.
Uni.IoC is a simple and fast dependency injection library.
Uni.Orm is the continuation of
Uni project. Project name is just changed.
Uni.Orm is a simple, fast and lightweight micro ORM. It has been developed as a compact single class library enabling to do the job with minimal effort just by using a few basic methods.