473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

running threads

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
responsiveness 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!
Mar 19 '08 #1
6 1619
What type of Timer are you using? If it's Windows.Forms.Timer you're not
using a background thread.

Maybe you can provide some detailed code of what you're doing in your
Tick/Elapsed event handlers?

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"garther" wrote:
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
responsiveness 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!
Mar 19 '08 #2
In the timer i'm running a thread

---
Thread Status = new Thread(statusJob);
Status.Start():
----
Peter Ritchie [C# MVP] pisze:
What type of Timer are you using? If it's Windows.Forms.Timer you're not
using a background thread.

Maybe you can provide some detailed code of what you're doing in your
Tick/Elapsed event handlers?
Mar 19 '08 #3
On Wed, 19 Mar 2008 10:12:30 -0700, garther <ma*****@cpartner.plwrote:
In the timer i'm running a thread

---
Thread Status = new Thread(statusJob);
Status.Start():
----
Why are you doing that? If you need for the timer event to be handled on
a separate thread, then use Threading.Timer which already runs the timer
event code on a different thread (it uses a thread pool thread). Starting
a whole new thread every time the timer elapses is wasteful and
unnecessary.

As Peter R. said, you really ought to be more specific about what you're
doing. Without describing in detail what timer you're using, how you're
using it, and what your code does in response to the timer, it's
impossible to suggest what might be causing the issue you're seeing.

Pete
Mar 19 '08 #4
It's hard to say what the problem could be with such little to go on.

I agree with Peter though, spawning an new thread on ever Timer tick isn't
the most efficient method.

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"garther" wrote:
In the timer i'm running a thread

---
Thread Status = new Thread(statusJob);
Status.Start():
----
Peter Ritchie [C# MVP] pisze:
What type of Timer are you using? If it's Windows.Forms.Timer you're not
using a background thread.

Maybe you can provide some detailed code of what you're doing in your
Tick/Elapsed event handlers?
Mar 19 '08 #5
So what method would you suggest for this purpose?
Peter Ritchie [C# MVP] pisze:
It's hard to say what the problem could be with such little to go on.

I agree with Peter though, spawning an new thread on ever Timer tick isn't
the most efficient method.
Mar 19 '08 #6
On Wed, 19 Mar 2008 13:03:14 -0700, garther <ma*****@cpartner.plwrote:
So what method would you suggest for this purpose?
Well, you haven't bothered to answer the questions asked you, including
"What type of Timer are you using?" The other relevant question asked but
not yet answered is "what are you doing in your elapsed event handlers?"

The only thing you've posted so far is code that suggests you're creating
a whole new thread every time the timer fires. From what little
information you've shared so far, it's impossible to tell you exactly how
to fix that, but it's pretty easy to know that it's almost certainly wrong
to do it the way you're doing it.

Pete
Mar 19 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Larry Woods | last post by:
I have a server page that has served an HTML page with a "Cancel" button on it, BUT this server page has not completed and is running a 15-30 second process before it completes. I want the browser...
3
by: MrFile | last post by:
C#.Net question for everyone I have a class that has a method that i run async from the Form. This class has one field string called log. I need this since i have an event that can write to it...
2
by: Raed Sawalha | last post by:
Hello: I have 2 windows application 1st one is periodically writing specific data to XML file , the 2nd application has a dialog with DataGrid , the datagrid filled with information in the XML...
2
by: Jeffrey Palermo, MCAD.Net | last post by:
I have some classes that control file processing in c#. The files come from a mainframe and may take some time for each to process. I use the Threadpool to process multiple files at once. Each...
7
by: mircu | last post by:
Hello, What would be the best for implementing architecture that runs several, independent, scheduled or run by the user on demand task in the same time? Now in my program every task creates...
4
by: Senthil | last post by:
Hi.. Can anyone tell how to find the threads(name or ID) running in the background using C#. I want to find those threads and to terminate if needed. Thanks, Palani.
4
by: Bill Thorne | last post by:
We have a COM object that has been wrappered for use in .NET and which can make calls which can take a while to execute. These are mainframe integration calls that might perform a lot of data...
5
by: hmoeller | last post by:
I'm looking for a way to find a specific running thread by name. I came across the System.Diagnostics.Process.Threads collection but unfortunately, this collection holds ProcessThread objects which...
1
by: DR | last post by:
what are the memory caps for threads running as a CLR stored procedure executed by sql server 2005? is it limited by OS only or also by sql servers memory limits? e.g. lets say my clr stored...
0
by: PromisedOyster | last post by:
We are having issues with our application periodically hanging. I have a timer event already running and I would like to know the state of all the running threads (foreground and background) so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.