Hi

I'm writing an application which basically takes images from pixelink camera and does some calculations on them.

I need to monitor the status of the system for 2 things: presence of camera and connection to SQL server.

I also have a preview feature.

Right now it's all being done by a two timers (one for preview and second for status) which run threads for status/preview.

On a decent Core 2 duo everything is quite smooth but on single core CPU responssivnes of the application is not so good (sometimes main form is frozen for couple of seconds).

How should i do those 2 processes so that they don't have an impact on application performance?

Thx for any info!

You can use the lock keyword provided by C# to avoid the critical sections code
You do a so to avoid conflicts between processes or threads unsafe in your case

private Object Critic = new Object();
//Safe code
.............
lock(Critic)
{
//Here you can put the critical block of code
............
}
//Safe code
..............

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.