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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How tdo I put the code of each user control on a form... in a thread??

Status
Not open for further replies.

tomcoombs

Programmer
Aug 14, 2003
65
GB
What I want to do is use my self writting "sound meter" user control many times in a C# form.

If one crashes, I do not want the rest to!!!


How can I do this?


Tom
 
i don't know enough about your 'sound meter', but if it is meant for a windows form, am i to believe it extends windows.form? if so, then each occurence of it should be a different thread. in fact, every time you use the keyword 'new', you start a new thread.
 
Hi Sean,

Thanks for your reply - makes good sense.

It extends the usercontrol class, does that help.

I also did a few tests like putting a sound meter into an infoinite oops - it crashes the whole prog. Any ideas. (Windows crtl - alt -del shows a constant 5 thread running too )

Tom
 
aah, well if it craches the whole prog then multiple thread wont help you (though they probably are running as seperate thread now, onlyless you were heavy on using 'static') - if one thread goes, it usually takes the program with it.

is it throwing exceptions, or just crashing because the tight loop is sucking up your resources?

if it's because of error/exceptions, try catching them. read the console output after the crash, it should have a record of the method statex. the first method from your app listed is usually the one that wants catching.

if the loop is too tight then control it with a timer to allow cpu space for other threads/progs.
 
Thanks again.


Back to the thread issue - Are you saying that a new thread is created whenever using the "new keyword"? So making a new string object creates a new thread??????

Tom
 
String yes, string no. i forgot about primatives, but it's true for every object.
 
Are you sure about that?

What I know; a struct (int, string, double) are always on the stack. And an object (Form, String, Control) are always references to an object on the heap.
It doesn't have anything to do with threads...

Markus
 
keep an eye of how many threads you have running as you create a new object. new object, new thread. the whole point of high level oop is that every object looks after itself - that's why they get a new thread, a recognised existance by the os to allow an object to manage itself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top