Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sound Library for C# Pin
Rodney S. Foley28-Aug-02 14:57
Rodney S. Foley28-Aug-02 14:57 
GeneralRe: Sound Library for C# Pin
leppie28-Aug-02 21:50
leppie28-Aug-02 21:50 
Questionhelp to use SetWindowsHookEx? Pin
imran_rafique28-Aug-02 0:31
imran_rafique28-Aug-02 0:31 
AnswerRe: help to use SetWindowsHookEx? Pin
Nnamdi Onyeyiri28-Aug-02 3:08
Nnamdi Onyeyiri28-Aug-02 3:08 
QuestionRaster Fonts? Pin
nbjahan28-Aug-02 0:19
nbjahan28-Aug-02 0:19 
QuestionIs this a bug? Pin
leppie27-Aug-02 22:21
leppie27-Aug-02 22:21 
AnswerRe: Is this a bug? Pin
leppie27-Aug-02 22:37
leppie27-Aug-02 22:37 
AnswerRe: Is this a bug? Pin
James T. Johnson28-Aug-02 6:49
James T. Johnson28-Aug-02 6:49 
It appears to be a bug with Refresh; you don't even need the timer object.

I modified your sample to put buttons below each grid, each button called refresh on the grid above it. Closing or opening one grid would cause the others to follow suit when their button was pressed.

BTW, there is a bug in your test program. You call Refresh from the System.Timers.TimerElapsed event; this results in the delegate being called on another thread where you shouldn't call any methods or set any properties except for BeginInvoke, EndInvoke, Invoke, and CreateGraphics.

To make it compliant I just made a minor change:

The code added first checks to see if it can execute properly, if it can't (InvokeRequired returns true) then I call Invoke on Form object passing in a delegate of the same type as the method (System.Timers.ElapsedEventHandler) and the two parameters as an array of objects. After the call to Invoke I return since the rest of the method has already completed.

void Timer(object sender, System.Timers.ElapsedEventArgs e)
{
    if( InvokeRequired )
    {
        Invoke(
            new System.Timers.ElapsedEventHandler(this.Timer), 
            new object [] { sender, e }
        );

        return ;
    }
 
    ...
}


James
"And we are all men; apart from the females." - Colin Davies
GeneralRe: Is this a bug? Pin
leppie28-Aug-02 7:09
leppie28-Aug-02 7:09 
GeneralRe: Is this a bug? Pin
James T. Johnson28-Aug-02 7:29
James T. Johnson28-Aug-02 7:29 
GeneralFileAccess Pin
Mazdak27-Aug-02 22:20
Mazdak27-Aug-02 22:20 
GeneralRe: FileAccess Pin
Rickard Andersson2027-Aug-02 22:30
Rickard Andersson2027-Aug-02 22:30 
GeneralRe: FileAccess Pin
Mazdak28-Aug-02 1:39
Mazdak28-Aug-02 1:39 
GeneralRe: FileAccess Pin
leppie28-Aug-02 1:53
leppie28-Aug-02 1:53 
GeneralRe: FileAccess Pin
Mazdak28-Aug-02 3:11
Mazdak28-Aug-02 3:11 
General.Net framework source code Pin
27-Aug-02 21:53
suss27-Aug-02 21:53 
Generalfind a string in another string Pin
Mazdak27-Aug-02 20:55
Mazdak27-Aug-02 20:55 
GeneralRe: find a string in another string Pin
Nnamdi Onyeyiri27-Aug-02 21:18
Nnamdi Onyeyiri27-Aug-02 21:18 
GeneralRe: find a string in another string Pin
Mazdak27-Aug-02 22:20
Mazdak27-Aug-02 22:20 
GeneralRe: find a string in another string Pin
Nnamdi Onyeyiri28-Aug-02 2:19
Nnamdi Onyeyiri28-Aug-02 2:19 
QuestionC# and null Structs? Pin
Rodney S. Foley27-Aug-02 18:01
Rodney S. Foley27-Aug-02 18:01 
AnswerRe: C# and null Structs? Pin
James T. Johnson27-Aug-02 18:18
James T. Johnson27-Aug-02 18:18 
GeneralRe: C# and null Structs? Pin
Rodney S. Foley27-Aug-02 18:47
Rodney S. Foley27-Aug-02 18:47 
GeneralRe: C# and null Structs? Pin
leppie27-Aug-02 21:33
leppie27-Aug-02 21:33 
GeneralRe: C# and null Structs? Pin
Rodney S. Foley28-Aug-02 8:18
Rodney S. Foley28-Aug-02 8:18 

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.