Click here to Skip to main content
15,899,314 members
Home / Discussions / C#
   

C#

 
QuestionXML Document Reader [modified] Pin
raghavsesh8-Sep-10 5:58
raghavsesh8-Sep-10 5:58 
AnswerRe: XML Document Reader Pin
Richard MacCutchan8-Sep-10 7:24
mveRichard MacCutchan8-Sep-10 7:24 
GeneralRe: XML Document Reader Pin
raghavsesh8-Sep-10 23:22
raghavsesh8-Sep-10 23:22 
AnswerRe: XML Document Reader Pin
PIEBALDconsult8-Sep-10 13:51
mvePIEBALDconsult8-Sep-10 13:51 
AnswerRe: XML Document Reader Pin
Luc Pattyn8-Sep-10 14:52
sitebuilderLuc Pattyn8-Sep-10 14:52 
GeneralRe: XML Document Reader Pin
PIEBALDconsult8-Sep-10 16:56
mvePIEBALDconsult8-Sep-10 16:56 
GeneralRe: XML Document Reader Pin
Luc Pattyn8-Sep-10 17:02
sitebuilderLuc Pattyn8-Sep-10 17:02 
GeneralRe: XML Document Reader Pin
raghavsesh8-Sep-10 23:47
raghavsesh8-Sep-10 23:47 
GeneralRe: XML Document Reader Pin
Pete O'Hanlon9-Sep-10 0:12
mvePete O'Hanlon9-Sep-10 0:12 
AnswerRe: XML Document Reader Pin
JohnLBevan9-Sep-10 1:48
professionalJohnLBevan9-Sep-10 1:48 
QuestionC# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 3:59
Keith Vitali8-Sep-10 3:59 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Ennis Ray Lynch, Jr.8-Sep-10 4:07
Ennis Ray Lynch, Jr.8-Sep-10 4:07 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 4:18
Keith Vitali8-Sep-10 4:18 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Ware@Work9-Sep-10 7:26
Ware@Work9-Sep-10 7:26 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Fayu8-Sep-10 4:22
Fayu8-Sep-10 4:22 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 4:34
Keith Vitali8-Sep-10 4:34 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Fayu8-Sep-10 5:19
Fayu8-Sep-10 5:19 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 5:23
Keith Vitali8-Sep-10 5:23 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Chris Trelawny-Ross8-Sep-10 5:39
Chris Trelawny-Ross8-Sep-10 5:39 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
HuntrCkr9-Sep-10 1:40
HuntrCkr9-Sep-10 1:40 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Luc Pattyn9-Sep-10 3:14
sitebuilderLuc Pattyn9-Sep-10 3:14 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
HuntrCkr9-Sep-10 3:35
HuntrCkr9-Sep-10 3:35 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Luc Pattyn9-Sep-10 3:50
sitebuilderLuc Pattyn9-Sep-10 3:50 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
HuntrCkr9-Sep-10 4:04
HuntrCkr9-Sep-10 4:04 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Peter Trevor9-Sep-10 4:57
Peter Trevor9-Sep-10 4:57 
I'm not sure how to satisfy Luc's issue over mixing sync and async behaviours, but how about this variation:

public void SetProgressValue(int value)
{
    MethodInvoker method = delegate
    {
        if (!formClosed)
        {
            m_progressBar.Value = value;
        }
    };
 
    if (InvokeRequired)
        BeginInvoke(method);
    else
        method.Invoke();
}


First, you don't need to worry about keeping the delegate's parameters aligned with the method's parameters (makes maintenance easier). Second, you shouldn't test boolean values against true/false (just take their value). Third, it uses the async BeginInvoke when not on the GUI thread.

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.