|
Yes, i think this is what you mean in the first reply.
Yes, it's a good logic, Adam. Can i say this is thread inside a thread?
And yes, i try it and it worked. I will try it on "large code".
Thanks Man!.
|
|
|
|
|
Yes, this is a thread inside a thread ... inside a thread.
Really when your application launches a thread is created, your main thread (Thread Count = 1), then when the user clicks the button you launch another thread (Thread Count = 2) then your 2nd thread creates another thread (Thread Count = 3).
This probably isnt the best method to accomplish this, see Luc's post, but it will get the job done.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
The count there is no use on "large code". I just want to examine that the threads is run on order or not.
Thanks for the suggestion about luc post.
|
|
|
|
|
Use a BackgroundWorker started when the button is clicked. The bgw can then either process each ComPort in sequence (as someone else said, if they are running sequentially, why bother with separate threads?), or the bgw can fire off its own child threads and wait for them to finish, as above. Because the bgw is doing the work, your form remains responsive while the long-running process is under way even if the bgw thread itself is paused or busy. Of course, you then have to decide what happens if someone tries to click the button again while the background thread is already running.
|
|
|
|
|
Thank you David for the reply.
Yes, i will keep it on my mind about BackgroundWorker. Until now, i had not use BackgroundWorker at my "large code" but suppose if i'm having trouble with the UI, i will try the BackgroundWorker.
|
|
|
|
|
if you want a number of operations to be executed in sequence, but without freezing your GUI, you need exactly one extra thread (Thread, ThreadPool thread, BackgroundWorker) that executes those operations one after the other.
And your GUI thread should never wait on them (nor on anything else) and not call Thread.Join(); instead you should keep your GUI active, however also disable the features you want disabled for as long as the other thread is working for you.
|
|
|
|
|
Thank you for the reply Luc.
Ok, i see there's 3 key point here to solve the problem :
1. Thread
2. ThreadPool
3. BackgroundWorker
I will investigate it further.
|
|
|
|
|
Endien wrote: 3 key point here to solve the problem
No, the key points are to keep the GUI/main thread free, never to block it, and to hire as many other team players as you need, no more, no less.
The exact type of your additional team player is of minor importance. BackgroundWorker is slightly harder to set up, but offers advantages for reporting progress, completion, and exceptions.
|
|
|
|
|
Hello...
How can I get the Length of a column of an sql table from my C# code....
In my application I am using databound controls. I want to know the length of the field in UI.
any help would be appreciated...
Thanks
Sebastian
|
|
|
|
|
|
See this[^] recent thread.
|
|
|
|
|
|
When I install the Code Project search toolbar, its background color is the default color for the Windows os it's running in -- that is, gray for XP, blue for Vista. I have made my own toolbar with a toolstrip in a Band Object, and everything works fine, except that I cannot get the background color to be the default. I can make a bitmap for the background, but if someone changes their theme my toolbar will then be the wrong color.
Susan
|
|
|
|
|
System.Drawing.SystemColors.WindowFrame Maybe ?
SystemColors Members[^]
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
I tried WindowFrame, and a whole bunch of others, none of which look like the color of the toolbars in Vista, which is my development operating system.
|
|
|
|
|
Well i'm out of ideas ..... Is it just the transparency of the toolbar that is making the colours differant? or is the colour just way off?
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
The color is way off -- but I'm not sure I understand what you mean by the transparency of the toolbar.
|
|
|
|
|
Well on Vista & 7 the toolbars have a slight transparency to them (Areo) which could mess with the colour.
Just a thought, have you tried enabling themes. I can't remeber where but I recal that being an issue with something I was working on awhile ago. I can't remember the object or actual property but I do remeber it was a problem. Might not help ... but you never know.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Thanks for the tip. I did some research and found the "Application.EnableVisualStyles" method. I called it from the constructor of my toolbar, and after I called it I displayed "Application.RenderWithVisualStyles", the value of which was true. However, my toolbar and its controls are still gray. Do you know how I should be setting the background color to work with EnableVisualStyles?
Susan
|
|
|
|
|
Now I have the controls painting in default Vista style, but the toolstrip itself is not.
|
|
|
|
|
I want to know what's the best way to make a windows form application in C# to connect people for online meeting? and what are tools available; for that?
|
|
|
|
|
The best way would be to design a client/server conferencing system that can handle duplex communication of audio, video and text, membership, authentication, and perhaps encryption. Some technologies you may want to examine are WCF, RIA services and Silverlight.
This is a non-trivial endeavour - your question is too open ended to provide a direct answer.
/ravi
|
|
|
|
|
Maybe use WebBrowser and Google Buzz?
|
|
|
|
|
I want to know how can I place the current time using analog clock on my windows form?
|
|
|
|
|
What are you talking about?
Nevertheless, there are a lot of analog clocks here on the CP. A couple of links:
Yet Another Analog Clock[^]
Analog Clock Control[^]
If you search for articles using the search word "analog clock", you will get 6 pages of links. There are A LOT - some good looking, others less good looking...
|
|
|
|