Click here to Skip to main content
15,917,795 members
Home / Discussions / C#
   

C#

 
GeneralRe: Modal Dialog help in C# [modified] Pin
Martin#29-Jun-06 6:11
Martin#29-Jun-06 6:11 
GeneralRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 6:30
Alexander Wiseman29-Jun-06 6:30 
GeneralRe: Modal Dialog help in C# Pin
Martin#29-Jun-06 6:41
Martin#29-Jun-06 6:41 
GeneralRe: Modal Dialog help in C# Pin
McSmack29-Jun-06 6:00
McSmack29-Jun-06 6:00 
QuestionRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 6:41
Alexander Wiseman29-Jun-06 6:41 
AnswerRe: Modal Dialog help in C# Pin
McSmack29-Jun-06 7:17
McSmack29-Jun-06 7:17 
QuestionRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 10:53
Alexander Wiseman29-Jun-06 10:53 
AnswerRe: Modal Dialog help in C# Pin
McSmack29-Jun-06 12:19
McSmack29-Jun-06 12:19 
Hey Alexander,

Hopefully I can answer these questions to the fullest


1) What symptoms cause you to think that the secondary thread is still running?

I'm most likely wrong, but it seems to be still running. My main form has a TextBox window that gives me updates of where the data control is at, and my ShowMyDialogBox() displays a transparent modal dialog over the main form. When I place the BeginInvoke(new MethodInvoker( this.ShowMyDialogBox)) line in my ShowMyDialogBox() method as you suggested, the dialog comes up and it is modal, but I can still see that the code is still running, displaying me updates in the main form's TextBox.


2) How is the thread created in the serial library? If you don't know, could you point me to the place on this site that has the serial library so I can check the code?


Here are the lines in the library that create the thread..

rcvNotifyThread = new Thread(new ThreadStart(RunRcvNotifyThread));
rcvNotifyThread.Priority = ThreadPriority.Normal;
rcvNotifyThread.Name = "Notify " + portName;
rcvNotifyThread.Start(); // Start the new thread



===========================================================
When you said that the MethodInvoker is just a delegate, it got me thinking. So I played around with it and found a good place to bring the secondary thread back to the main thread. Upon entry of my callback function, I decide to place your solution here since the method that runs all my data processing matches the MethodInvoker delegate. See below


public void ReceiveDataFromSerial(); //Just here to show you the prototype

// the method that implements the delegated funtionality
public void ProcessIncomingData( )
{
string testString = "Thread is named: " + System.Threading.Thread.CurrentThread.Name;
System.Diagnostics.Trace.WriteLine(testString);
Console.WriteLine(testString);

//If not in the main thread, move there and let old thread end
if(this.InvokeRequired)
{
this.BeginInvoke(new MethodInvoker(this.ReceiveDataFromSerial));
return;
}

// Process Data
ReceiveDataFromSerial(); // This function process all
}


This seems to do the trick. I will keep testing it to make sure everything is sound.

I truly appreciate all your help Alexander.

Regards,
McSmack
GeneralRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 12:54
Alexander Wiseman29-Jun-06 12:54 
QuestionQuick button question [modified] Pin
Arkon94828-Jun-06 13:05
Arkon94828-Jun-06 13:05 
AnswerRe: Quick button question [modified] Pin
Mike Poz28-Jun-06 13:45
Mike Poz28-Jun-06 13:45 
QuestionExporting to SPSS issue Pin
Nader Elshehabi28-Jun-06 11:59
Nader Elshehabi28-Jun-06 11:59 
AnswerRe: Exporting to SPSS issue Pin
farquem828-Jun-06 16:01
farquem828-Jun-06 16:01 
GeneralRe: Exporting to SPSS issue Pin
Nader Elshehabi28-Jun-06 17:29
Nader Elshehabi28-Jun-06 17:29 
QuestionASP.net and Javascript Pin
Naji.A28-Jun-06 11:27
Naji.A28-Jun-06 11:27 
AnswerRe: ASP.net and Javascript Pin
Guffa28-Jun-06 12:06
Guffa28-Jun-06 12:06 
GeneralAny helpful hints? Pin
Naji.A28-Jun-06 12:12
Naji.A28-Jun-06 12:12 
AnswerRe: Any helpful hints? Pin
Guffa28-Jun-06 19:31
Guffa28-Jun-06 19:31 
GeneralError Messages? [modified] Pin
Naji.A29-Jun-06 22:01
Naji.A29-Jun-06 22:01 
AnswerRe: Error Messages? Pin
Guffa30-Jun-06 5:25
Guffa30-Jun-06 5:25 
GeneralDon't see any error messages!!! [modified] Pin
Naji.A30-Jun-06 11:44
Naji.A30-Jun-06 11:44 
GeneralRe: Don't see any error messages!!! Pin
Guffa1-Jul-06 4:47
Guffa1-Jul-06 4:47 
GeneralNot Sure! Pin
Naji.A2-Jul-06 11:15
Naji.A2-Jul-06 11:15 
GeneralRe: Not Sure! Pin
Guffa3-Jul-06 0:34
Guffa3-Jul-06 0:34 
GeneralPage Structure Pin
Naji.A3-Jul-06 12:26
Naji.A3-Jul-06 12:26 

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.