|
Hi, you may want to read up on the Thread.ThreadState property
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
I've allready thought of using that property untill i realise it wasn't possible ...
Actually, using ThreadState is not reliable since threads are most of the time in WaitSleepJoin mode due to time-slicing
Best Regards,
Mamat,
|
|
|
|
|
In a process where there isn't much calculations going on (say a text editor) all
the threads are likely to be waiting for something to happen, such as a keyboard hit,
a mouse move, whatever.
In a process with lengthy calculations you will see threads that are not in WaitSleepJoin
state. Here is a simple test:
void Test() {
List<Thread> threads=new List<Thread>();
for(int i=0; i<4; i++) {
Thread t=createThread("T"+i);
threads.Add(t);
}
for(int i=0; i<100; i++) {
Thread.Sleep(300);
Console.WriteLine("tick "+i);
foreach(Thread t in threads) {
Console.WriteLine("Thread "+t.Name+": state = "+t.ThreadState);
}
}
}
Thread createThread(string name) {
Thread t=new Thread(new ThreadStart(runner));
t.IsBackground=true;
t.Priority=ThreadPriority.BelowNormal;
t.Name=name;
t.Start();
return t;
}
void runner() {
for(int j=0; j<100; j++) {
for(int i=0; i<100000000; i++) { }
Thread.Sleep(1000);
}
}
Half of the time, some of the threads are in WaitSleepJoin (due to the Thread.Sleep in
runner), the other times they are really running.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
This is what i've read from MSDN :
"Your code should never use thread state to synchronize the activities of threads."
Would be so easy that way, too bad it can't work ...
Do you have any other idea ?
Best Regards,
Mamat,
|
|
|
|
|
Karma Komae wrote: Do you have any other idea ?
Yes. Start by stating your problem.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi All,
I have collection of Url's in my list box ,and these url's contain path to some .js files. What I want is that when user double click on of these url, file should open in notepad. Currently am opening a file in firefox. I don't want to download the file I jsut want to open a file. So am not using web.Client.DownLoad()
Any Idea please help.
thanks,
A.Asif
|
|
|
|
|
why not just download the file to the temp directory, then run the command "%SystemRoot%\System32\notepad.exe %Temp%\file.js". When you are done, you can delete the file, or just leave it to be deleted by the user when he or she clears the temp directory.
Jeff
|
|
|
|
|
Hi friends,
Can any one help me in, How can i read the data from MSSQl server (Let us say at x database and all tables in that database) and then convert data in to a text format and so that i can save and upload that data into [b]MySql [/b]Data base.
I was following a procedure which is satisfactory for few tables but as the table number and size grows my procedure will become a tedious one.
Anyhow i will tell the procedure i am following
I created a DataIntegrationServices Project which is available in MSSQL2005 server Business Intelligence Development Studio.
There i created a dataflowtask where we can give the origin and destination files. Origin was a OLEDB connection to connect the database and destination was a FlatFile. In this way i can convert data from one table to the text format with delimiters we select.
But i need to convert some hundred tables, can any one help me in this regard.
I use C# language for developing my applications.
Can any one suggest me an alternative or enhance the same procedure by certain modifications.
Please don't suggest third party tools which i have to buy, i prefer working with code or free available tools.
Thank you in advance.
N.Raghavendran.
Raghavendran
|
|
|
|
|
There is an open source tool here that might do what you're after.
Google is your friend. Use him, that's what friends are for.;P
"You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"
|
|
|
|
|
Hi.
I want to notify the user when a certain background event is triggered.
I do this by showing a small form in the task bar (it is already minimized) with
the ShowDialog() method.
The problem is, however that when the form appears in the task bar, it also gets focus, so if the user is writing something in Notepad (for ex.), he is interrupted by this.
Therefore, I need a solution to prevent the new window from getting the focus.
Any ideas?
Thanks.
PS: I know that this can also be done with a notify icon, but fro now that's my second option.
|
|
|
|
|
Why not do the following...
1. Set the popup form's Visible property to false, and WindowState to Minimized in the designer
2. Create a new instance of that form (the popup window) on initialization of the class that currently calls ShowDialog
3. Instead of calling ShowDialog, change the Visible property on the popup to true
Will this work, or does it have to be a modal dialog (or does it still get focus)?
Jeff
|
|
|
|
|
|
Hi all,
I'm trying to load an image from my .resx file and place it into the image property of the toolStripStatusLabel. How can I do this or am I going at it wrongly ??
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
In a project of mine I had the images within the global resources file. To gain access to those resources I used:
toolStripLabel1.Image = global::MyProject.Properties.Resources.CloseImg;
Of course I manually inserted the images in the project's resource file.
Hope it helps.
I will use Google before asking dumb questions
|
|
|
|
|
|
Hi friends,
I have a requirement to send Messages to Mobile devices? I am new to this technology.. what is the namespace used for this?
can we import any buit in components?
How we know the providers and how we can contact with them?
How can we do it in c#?
If any one has on idea regarding this, send me the links for me
if possible send me a code for me.
thanks in advance
|
|
|
|
|
Check out http://www.smscountry.com/[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
hi i am making an applicaiton that draws the rectangles using mouse,when mouse is down it takes the starting points of rectangle(x,y) and when mouse moves then ending point of rectangle are taken and rectangle is drawn,here is code of that
<br />
private void frmMedtronic_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
if (mIsMouseDown)<br />
{<br />
if (e.Location.X > mrctRectangle.X)<br />
mrctRectangle.Width = e.Location.X - mrctRectangle.X;<br />
else
{<br />
mrctRectangle.X = e.Location.X; <br />
mrctRectangle.Width = e.Location.X - mrctRectangle.X;<br />
}<br />
<br />
if (e.Location.Y > mrctRectangle.Y)<br />
mrctRectangle.Height = e.Location.Y - mrctRectangle.Y;<br />
else
{<br />
mrctRectangle.Y = e.Location.Y; <br />
mrctRectangle.Height = e.Location.Y - mrctRectangle.Y;<br />
}<br />
}<br />
Invalidate();<br />
}<br />
and in formpaint drawrectangle function is called.
The problem is in moving rectangle toward left or moving upwards,as in this case ending points are greater then starting and in drawing as widht and height of rectangle can only b positive values not negative,i am having trouble in moving towards upward and left as point of screen are from 0 and not negative as in openGL, so suggest me what to do.
Regards.
Tasleem Arif
|
|
|
|
|
Try this:
int StartX = (e.Location.X > mrctRectangle.X ? e.Location.X : mrctRectangle.X);
int StartY = (e.Location.Y > mrctRectangle.Y ? e.Location.Y : mrctRectangle.Y);
int EndX = (e.Location.X < mrctRectangle.X ? e.Location.X : mrctRectangle.X);
int EndY = (e.Location.Y < mrctRectangle.Y ? e.Location.Y : mrctRectangle.Y);
You have here the start and end points of an rectangle. Hope it helps.
I will use Google before asking dumb questions
|
|
|
|
|
Hi,
this looks the easiest to me: store MouseDown point in pt1, current MouseMove position in pt2,
and in OnPaint for both x and y do:
xMin= x1<=x2 ? x1 : x2;
width= x1+x2-xMin -xMin;
ADDED: then Graphics.DrawRectangle(..., xMin, yMin, width, height);
BTW: You might want to add 1 to width/height to always see the rectangle...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hello,
I would like to know the way to use the Serialport class for receiving the data from more than a port at a time. I mean, how to create multiple threads at a time so as to read the data from multiple ports?
Techie..
|
|
|
|
|
There's no restriction on the number of SerialPort instances can be created, so all you need to do is create a SerialPort instance for eacht port you want to use and add eventhandlers for each ports DataReceived event.
Standards are great! Everybody should have one!
|
|
|
|
|
hi everyone!
i created a service and an installer.
the service works fine when testing it as an executeable.
when i install it and choose "automatic" (start mode) then it does not start but displays a message telling me, services in idle mode are sometimes stopped.
i guess i forgot to add an option to not allow termination or similar.
could anyone tell me where the problem might be located?
thanks!
stephan.
|
|
|
|
|
There's an exception occurring somewhere in your startup procedure. Check the event viewer to see if something has appeared in there - and log any exceptions that you encounter/consume.
|
|
|
|
|
Hi,
I've to read display the contetns of a folder that is placed on a web server. For instance i've to display the contents of http://localhost on in a list view of my windows application. Please help me out. It would be nice of you.
Arslan Ilyas
|
|
|
|