Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
GeneralRe: printer Pin
help as an alias7-Aug-07 1:37
help as an alias7-Aug-07 1:37 
AnswerRe: printer Pin
Hessam Jalali7-Aug-07 2:14
Hessam Jalali7-Aug-07 2:14 
QuestionThreadiing Pin
james_dixon_20087-Aug-07 0:27
james_dixon_20087-Aug-07 0:27 
AnswerRe: Threadiing Pin
Christian Graus7-Aug-07 0:42
protectorChristian Graus7-Aug-07 0:42 
GeneralRe: Threadiing Pin
james_dixon_20087-Aug-07 1:28
james_dixon_20087-Aug-07 1:28 
GeneralRe: Threadiing Pin
Tristan Rhodes7-Aug-07 2:04
Tristan Rhodes7-Aug-07 2:04 
GeneralRe: Threadiing Pin
james_dixon_20087-Aug-07 3:00
james_dixon_20087-Aug-07 3:00 
GeneralRe: Threadiing Pin
pbraun7-Aug-07 4:44
pbraun7-Aug-07 4:44 
I see some problems in your code.

1. What happens when you hit the start button a few times without waiting for the thread to finish.

2. Invoking the delegate from the thread does work from your thread, but this method requires that each object calling to the new_try() method know about the delegate and call that.

3. If the new_try() method is called from any other thread than the GUI thread, it will take time to execute the call.

The new_try() method should take the form of

public delegate void new_try_delegate();
new_try_delegate newTryEvent = new new_try_delegate(new_try);

public void new_try()
{
   if (this.InvokeRequired)
   {
      Invoke.Begin( newTryEvent );
   }
   else
   {
      textBox1.Text += "This is new Thread" + Environment.NewLine;
   }
}


Now you can call new_try() from any other thread and the GUI thread will do the work of displaying the string.

As for the first problem, you should always check to see if the thread is running before starting another instance of that thread so that the user doesn't run themselves out of resources.

Phil

GeneralRe: Threadiing Pin
Tristan Rhodes7-Aug-07 5:00
Tristan Rhodes7-Aug-07 5:00 
GeneralRe: Threadiing Pin
james_dixon_20087-Aug-07 6:40
james_dixon_20087-Aug-07 6:40 
GeneralRe: Threadiing Pin
Tristan Rhodes7-Aug-07 4:46
Tristan Rhodes7-Aug-07 4:46 
QuestionDefault program of file. Pin
Rahul.RK7-Aug-07 0:26
Rahul.RK7-Aug-07 0:26 
AnswerRe: Default program of file. Pin
Christian Graus7-Aug-07 0:44
protectorChristian Graus7-Aug-07 0:44 
GeneralRe: Default program of file. Pin
Tormod Fjeldskaar7-Aug-07 0:49
Tormod Fjeldskaar7-Aug-07 0:49 
GeneralRe: Default program of file. Pin
Vasudevan Deepak Kumar7-Aug-07 0:49
Vasudevan Deepak Kumar7-Aug-07 0:49 
GeneralRe: Default program of file. Pin
Tormod Fjeldskaar7-Aug-07 1:16
Tormod Fjeldskaar7-Aug-07 1:16 
AnswerRe: Default program of file. Pin
Kumar Arun7-Aug-07 1:36
Kumar Arun7-Aug-07 1:36 
AnswerRe: Default program of file. Pin
Hessam Jalali7-Aug-07 1:47
Hessam Jalali7-Aug-07 1:47 
GeneralRe: Default program of file. Pin
Rahul.RK7-Aug-07 18:31
Rahul.RK7-Aug-07 18:31 
QuestionError while assigning value to a cell in a DataTable Pin
Vishnu Govind7-Aug-07 0:00
Vishnu Govind7-Aug-07 0:00 
AnswerRe: Error while assigning value to a cell in a DataTable Pin
Elayaraja Sambasivam7-Aug-07 0:11
Elayaraja Sambasivam7-Aug-07 0:11 
GeneralRe: Error while assigning value to a cell in a DataTable Pin
Vishnu Govind7-Aug-07 1:38
Vishnu Govind7-Aug-07 1:38 
GeneralRe: Error while assigning value to a cell in a DataTable Pin
Vishnu Govind7-Aug-07 2:04
Vishnu Govind7-Aug-07 2:04 
Questiondetail section of crystal report. Pin
monuSaini6-Aug-07 23:28
monuSaini6-Aug-07 23:28 
AnswerRe: detail section of crystal report. Pin
Elayaraja Sambasivam7-Aug-07 0:16
Elayaraja Sambasivam7-Aug-07 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.