Calling Synchronous Methods Asynchronously with different Patterns

There are several patterns to call a synchronous method asynchronously as shown below.

1- BeginInvoke and EndInvoke
2- WaitHandle
3- Polling
4- Callback

 

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.

Figure-1

Figure-2

Figure-3

Continue reading

File copying on Network showing with Asynchronous Progress Bar in Console Application

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.

Continue reading

Asynchronous Progress Bar in Console Application

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.


Continue reading

Homebrew package manager for Mac OS

Homebrew is a package manager for Mac OS. You can find more details in http://brew.sh . You can install and uninstall software that you need easily from Command Line Interface. You can read http://kenanhancer.com/2016/10/27/chocolatey-package-manager-for-windows/ for Windows package manager. I think this explanation is enough. Let’s see how to use brew.

Homebrew main page

http://brew.sh

Continue reading

Creating Simple Web Project Using Nodejs, Gulp, CoffeeScript, SASS, Less, Stylus, Jade, Haml, Express Framework etc.

This article purpose is to create a web project using some popular technologies. So, after read this article, you will be informed how you can use these technologies together. (Nodejs, Gulp, CoffeeScript, SASS/SCSS, Less, Stylus, Jade, Haml, Express Web Framework, etc.). Maybe you will change point of view and start to discover more.

Firstly, I think that we should have a package manager. So, I will use Chocolatey in Windows. If you don’t have in your computer, you can read http://kenanhancer.com/2016/10/27/chocolatey-package-manager-for-windows/

Continue reading