Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do avoid flickering win form

Status
Not open for further replies.

tsisher

Programmer
Sep 14, 2004
36
GB
Hi,
I have a method which process the files(read/create many files) which I am calling like that..

Thread t = new Thread(new ThreadStart(ProcessFiles));
t.Start();

ProcessFiles() is the method which does all the file work.

Every think works fine but my win form keeps flickering which I don't want.
Is there any think I can do to avoid flickering.
Many Thanks,



 
Now I have found while the method is processing the files and if I move to some other window,
for example while it is processing and say I open internet explorer or windows explore they start flickering heavily. Even the internet explore is not allowing me to type the url. Where the focus goes it starts flickering.

And I am making this utility to run all the time that means I can't do any thing on this system at all.

Please Please help.

 
I wouldn't use a [tt]new Thread()[/tt] to process this asynchronisly. Instead I would use a BackGroundWorker object. this is much more robust.

Have you tried executing your event synchronisly? Does this cause the same preformance hit? it may be that the process is resource intensive, or has a memory leak.

You could also design your routine to create async handlers which could manage the process in the background.

If this is a routine that constantly runs in the background you may want to creat it as a Windows Service instead of a desktop application. As a Windows Service it can run like all other system services seperate from user logon, or application state.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks Jason,
At last I got some input. I'll start looking at BackGroundWorker object.
You did mention about async handlers.
What are those?
Do you have any sample?
Regards,
 
Are you updating the main thread GUI?

You may need to slap in a short Sleep in your thread or an Application.DoEvents.

This utility runs all the time? It's probably eating your processing power. Putting in a slightly longer sleep will help with that, or make your Process lower priority than normal.
 
in the MSDN help (F1) use the index to find asynchronis events. there is a caluclate prime number example which creates a event to run asynchronisly.

sorry this isn't more helpful. I'm not at my primary computer right now to look it up.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
If this is a process that is "working all the time" I would think you'd be better off creating a Windows Service application.

You can create timer threads that will run every hour or whatever time interval you want to use. It triggers a callback which will run your process for you automatically.

Does this application really need a UI?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top