Click here to Skip to main content
16,005,552 members
Home / Discussions / C#
   

C#

 
AnswerRe: Getting Error when using System.Timers.Timer Pin
Andrei Ungureanu21-Nov-07 0:22
Andrei Ungureanu21-Nov-07 0:22 
GeneralRe: Getting Error when using System.Timers.Timer [modified] Pin
Satish - Developer21-Nov-07 0:27
Satish - Developer21-Nov-07 0:27 
AnswerRe: Getting Error when using System.Timers.Timer Pin
Rob Philpott21-Nov-07 0:29
Rob Philpott21-Nov-07 0:29 
GeneralRe: Getting Error when using System.Timers.Timer Pin
Satish - Developer21-Nov-07 0:33
Satish - Developer21-Nov-07 0:33 
QuestionProblem sending email to Lotus iNote Pin
Jedidah20-Nov-07 23:53
Jedidah20-Nov-07 23:53 
QuestionAccessing Control.Focused property from Thread Pin
Sukhjinder_K20-Nov-07 23:36
Sukhjinder_K20-Nov-07 23:36 
AnswerRe: Accessing Control.Focused property from Thread [modified] Pin
Martin#20-Nov-07 23:44
Martin#20-Nov-07 23:44 
GeneralRe: Accessing Control.Focused property from Thread Pin
Stevo Z21-Nov-07 0:28
Stevo Z21-Nov-07 0:28 
To my knowledge, it's not thread safe this way, let me explain :

bool listFocused()
{
    // lets say this method is called from thread [T1], different from main application thread [T0] (thread that that listbox was created on)

    if(this.list.InvokeRequired) // if this condition is true, we are on [T1]
    {
        ListFocusCallBack d = new ListFocusCallBack(listFocused); // still [T1]
        this.list.Invoke(d, new object[] {}); // 'd' executes on [T0] !! [T1] is blocked until Invoke finishes

       // now we're back at [T1] !!
    }

    return this.list.Focused; // !!! again [T1] - if u invoke a delegate using control invoke, it doesn't mean
                              // that the rest of this method will be executed on that invoked thread. it
                              // remains on thread [T1], where it's not safe to get the Focused value.
}


what you need to do is to return value that Control.Invoke method returns

bool listFocused()
{
    // [T1]

    if(this.list.InvokeRequired) // if on other than [T0]
    {
         ListFocusCallBack d = new ListFocusCallBack(listFocused);
         return (bool)this.list.Invoke(d, new object[] {}); // wait for Invoked method to finish and return result (again on [T1])       
    }
    
    else // [T0] now we are sure this is thread safe 
    {
        return this.list.Focused; 
    } 
}







zilo

GeneralRe: Accessing Control.Focused property from Thread [modified] Pin
Martin#21-Nov-07 0:41
Martin#21-Nov-07 0:41 
GeneralRe: Accessing Control.Focused property from Thread Pin
Stevo Z21-Nov-07 1:29
Stevo Z21-Nov-07 1:29 
GeneralThank you! Pin
Martin#21-Nov-07 1:59
Martin#21-Nov-07 1:59 
GeneralRe: Thank you! Pin
Stevo Z21-Nov-07 2:10
Stevo Z21-Nov-07 2:10 
GeneralThanks Everybody Pin
Sukhjinder_K23-Nov-07 5:33
Sukhjinder_K23-Nov-07 5:33 
Questionit send data to tcp/ip port number, ex 8080, now i want to write socket program to read data from that port. Any body help me? How can i do that? Pin
sivaramireddy p20-Nov-07 23:21
sivaramireddy p20-Nov-07 23:21 
GeneralPlease stay away of this forum! Pin
Martin#20-Nov-07 23:26
Martin#20-Nov-07 23:26 
GeneralRe: Please stay away of this forum! Pin
Bekjong20-Nov-07 23:52
Bekjong20-Nov-07 23:52 
AnswerRe: it send data to tcp/ip port number, ex 8080, now i want to write socket program to read data from that port. Any body help me? How can i do that? Pin
Andrei Ungureanu20-Nov-07 23:50
Andrei Ungureanu20-Nov-07 23:50 
AnswerRe: it send data to tcp/ip port number, ex 8080, now i want to write socket program to read data from that port. Any body help me? How can i do that? Pin
Andrei Ungureanu21-Nov-07 0:03
Andrei Ungureanu21-Nov-07 0:03 
AnswerRe: it send data to tcp/ip port number, ex 8080, now i want to write socket program to read data from that port. Any body help me? How can i do that? Pin
Pete O'Hanlon21-Nov-07 0:04
mvePete O'Hanlon21-Nov-07 0:04 
GeneralRe: it send data to tcp/ip port number, ex 8080, now i want to write socket program to read data from that port. Any body help me? How can i do that? Pin
Andrei Ungureanu21-Nov-07 0:06
Andrei Ungureanu21-Nov-07 0:06 
GeneralHow to cook fries. Urgent. Plz Help. Pin
Malcolm Smart21-Nov-07 1:10
Malcolm Smart21-Nov-07 1:10 
JokeRe: How to cook fries. Urgent. Plz Help. Pin
Pete O'Hanlon21-Nov-07 1:14
mvePete O'Hanlon21-Nov-07 1:14 
QuestionPInvoke in c# Pin
m@u20-Nov-07 22:43
m@u20-Nov-07 22:43 
AnswerRe: PInvoke in c# Pin
Malcolm Smart21-Nov-07 1:12
Malcolm Smart21-Nov-07 1:12 
GeneralRe: PInvoke in c# Pin
m@u21-Nov-07 1:48
m@u21-Nov-07 1:48 

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.