Click here to Skip to main content
15,887,999 members
Home / Discussions / C#
   

C#

 
GeneralRe: Curious Bug Pin
JamesBarnes8-Aug-07 5:37
JamesBarnes8-Aug-07 5:37 
QuestionGetting a computer name from the IP address(C#) Pin
WvdW8-Aug-07 4:23
WvdW8-Aug-07 4:23 
AnswerRe: Getting a computer name from the IP address(C#) Pin
led mike8-Aug-07 4:46
led mike8-Aug-07 4:46 
AnswerRe: Getting a computer name from the IP address(C#) Pin
Hessam Jalali8-Aug-07 5:06
Hessam Jalali8-Aug-07 5:06 
GeneralRe: Getting a computer name from the IP address(C#) Pin
WvdW8-Aug-07 5:38
WvdW8-Aug-07 5:38 
GeneralRe: Getting a computer name from the IP address(C#) Pin
Hessam Jalali8-Aug-07 5:45
Hessam Jalali8-Aug-07 5:45 
GeneralRe: Getting a computer name from the IP address(C#) Pin
WvdW8-Aug-07 6:24
WvdW8-Aug-07 6:24 
QuestionAccessing Windows Form through a Thread of another Thread Pin
ictoane8-Aug-07 3:51
ictoane8-Aug-07 3:51 
Hello,

I posted this on msdn thread too but haven't gotten any answer yet so was wondering if you guys can help.

===================
Ahh question about accessing Windows form from a thread created through thread.

When I tried to make sure it's thread-safe, it keeps looping back into InvokeRequired because for some reason the calling thread and creating thread are never the same... Here's a watered down example...



private void blahblahblah()<br />
{<br />
<br />
Thread t = new Thread(method);<br />
t.Start(); <br />
<br />
}<br />
<br />
private void method()<br />
{<br />
<br />
if(InvokeRequired)<br />
{<br />
<br />
// Invokes this method back so that it can also call Windows Form<br />
<br />
}<br />
<br />
else<br />
{<br />
<br />
for(int i = 0; i < Number; i++)<br />
{<br />
<br />
// Do something to Windows Form<br />
<br />
Timer timer = new Timer();<br />
timer.Elapsed += new ElapsedEventHandler(andAnother);<br />
_Event.WaitOne();<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
 <br />
<br />
private void andAnother()<br />
{<br />
<br />
if(InvokeRequired)<br />
{<br />
<br />
// Keeps coming back to this part<br />
<br />
EventHandler Handler = new EventHandler(andAnother);<br />
this.Invoke(Handler, sender, e);<br />
<br />
}<br />
<br />
else<br />
{<br />
<br />
// Never gets here <br />
// Doing something to Windows Form<br />
// Trying to Set _Event<br />
<br />
_Event.Set();<br />
<br />
}<br />
<br />
}



So on both threads, I want to access Windows Form. The first thread is good but the second thread that was created through the first thread loops through InvokeRequired.


Thanks!
AnswerRe: Accessing Windows Form through a Thread of another Thread Pin
Luc Pattyn8-Aug-07 4:13
sitebuilderLuc Pattyn8-Aug-07 4:13 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
ictoane8-Aug-07 4:56
ictoane8-Aug-07 4:56 
AnswerRe: Accessing Windows Form through a Thread of another Thread Pin
pbraun8-Aug-07 4:42
pbraun8-Aug-07 4:42 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
ictoane8-Aug-07 5:08
ictoane8-Aug-07 5:08 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
Luc Pattyn8-Aug-07 5:19
sitebuilderLuc Pattyn8-Aug-07 5:19 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
ictoane8-Aug-07 5:30
ictoane8-Aug-07 5:30 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
Luc Pattyn8-Aug-07 5:45
sitebuilderLuc Pattyn8-Aug-07 5:45 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
ictoane8-Aug-07 6:35
ictoane8-Aug-07 6:35 
GeneralRe: Accessing Windows Form through a Thread of another Thread Pin
pbraun8-Aug-07 8:34
pbraun8-Aug-07 8:34 
QuestionRpc Server Unavailable in Excel Com Object Pin
sakthi dasan8-Aug-07 3:49
sakthi dasan8-Aug-07 3:49 
AnswerRe: Rpc Server Unavailable in Excel Com Object Pin
- Pascal -8-Aug-07 18:27
- Pascal -8-Aug-07 18:27 
GeneralRe: Rpc Server Unavailable in Excel Com Object Pin
sakthi dasan8-Aug-07 23:15
sakthi dasan8-Aug-07 23:15 
Questionqueue of string arrays syntax Pin
Lord_Veralix8-Aug-07 3:43
Lord_Veralix8-Aug-07 3:43 
AnswerRe: queue of string arrays syntax Pin
Hessam Jalali8-Aug-07 4:02
Hessam Jalali8-Aug-07 4:02 
GeneralRe: queue of string arrays syntax Pin
Lord_Veralix8-Aug-07 4:07
Lord_Veralix8-Aug-07 4:07 
QuestionDataGridView multi-column sort on bound data Pin
Dana Tov8-Aug-07 3:38
Dana Tov8-Aug-07 3:38 
QuestionForm.Show() and TabControl tab page changed Pin
C-Scharbe8-Aug-07 3:25
C-Scharbe8-Aug-07 3:25 

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.