Rashim's Blog

Simple Way to Develop Server Software for File Manipulation

Posted on: March 19, 2012

We, the developers, always try to look into the performance when we develop an application. Is there any developer who wants his application to freeze or smash? But what are the steps a developer should yield to keep it all smooth going. When I used to develop this application, I saw whenever I attempt to copy files from one directory to other it includes CPU as well as hard drive. The major fallback of it is to limit a user to execute one task at a time. So how do we deal with application freezing and smashing?

By using threads through which we can handle all the jobs simultaneously under one main application thread. You can perform smaller operations with the help of threading class; instead I prefer using Background Worker class to implement to perform all my heavy duty operations. Background Worker is used to execute long running operations on a separate thread, support cancellation, progress reporting and marshalling results back to the UI thread. As I have offered the smooth UI which shows the operation details and at the same time the operation will continue in the background, I choose this one to use. If you want to know in details about the Background Worker, you can read this article.

The main mechanism is that when the user clicks the start button, it issues the event OnCopyStarted and the event handler is responsible for Copying data while at the same time OnUIChanged was getting issued and do some enable/disable UI Controls, when we click stop button, it issued the OnCopyStoppedEvent and at the same time it checks the Background worker’s working status does Background worker finish/Cancel its task or not. If not, it pops up the dialog window for a moment and waits for Background worker to be free, once the Backgroundworker gets free, the Dialogue will automatically dispose. Here I have used one way binding. So any changes in property value will reflect to the UI but changing the UI will not reflect on the properties.

You will find the full article here[^]

Advertisements

2 Responses to "Simple Way to Develop Server Software for File Manipulation"

if you need to do a lot of IO like finding files etc… use WIN32 API like FindFirstFileW instead of DIrectory.GetFiles… way faster and ofcouse always use async calls to them..

Yes…But this time i just show how to start without considering other stuffs. I agree with you. Thanks for your advice.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: