Click here to Skip to main content
15,925,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading issue in winforms Pin
Judah Gabriel Himango1-Apr-09 17:46
sponsorJudah Gabriel Himango1-Apr-09 17:46 
GeneralRe: Threading issue in winforms Pin
Mycroft Holmes1-Apr-09 17:56
professionalMycroft Holmes1-Apr-09 17:56 
GeneralRe: Threading issue in winforms Pin
N a v a n e e t h1-Apr-09 17:34
N a v a n e e t h1-Apr-09 17:34 
GeneralRe: Threading issue in winforms Pin
Mycroft Holmes1-Apr-09 17:54
professionalMycroft Holmes1-Apr-09 17:54 
GeneralRe: Threading issue in winforms Pin
N a v a n e e t h1-Apr-09 17:59
N a v a n e e t h1-Apr-09 17:59 
GeneralRe: Threading issue in winforms Pin
Mycroft Holmes1-Apr-09 18:10
professionalMycroft Holmes1-Apr-09 18:10 
GeneralRe: Threading issue in winforms Pin
N a v a n e e t h1-Apr-09 18:15
N a v a n e e t h1-Apr-09 18:15 
GeneralRe: Threading issue in winforms Pin
Luc Pattyn2-Apr-09 4:37
sitebuilderLuc Pattyn2-Apr-09 4:37 
Hi Mycroft,

getting the DataTable is what takes most of 10 seconds and needs to be delegated to a thread.
Your LoadGrid() method uses Invoke to cause the GUI thread to do it anyway, so your efforts to speed up things are pointless so far.

Here is unchecked code to get the DataTable on the thread and the DGV update on the UI thread;
it does not rely on any fancy C# code, it should work on all .NET versions:

private void LoadGrid(DataTable dtAttr)	{
	if (this.InvokeRequired) {
		// execute on current thread
		dtAttr = cashFlow.GetAttrForCashflow(cashFlow.CashflowID);
		this.BeginInvoke(new LoadGridDelegate(LoadGrid), dtAttr );
	} else {
		// execute on GUI thread
		UIUtils.dgLoad(dtAttr, dtAttr.DefaultView, "");
	}
}


With anonymous methods/delegates you can further simplify it as others have shown.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


QuestionVS 2008 Unit Testing Null Exception Error Pin
dboy2211-Apr-09 15:57
dboy2211-Apr-09 15:57 
AnswerRe: VS 2008 Unit Testing Null Exception Error Pin
Judah Gabriel Himango1-Apr-09 16:42
sponsorJudah Gabriel Himango1-Apr-09 16:42 
GeneralRe: VS 2008 Unit Testing Null Exception Error Pin
dboy2211-Apr-09 17:22
dboy2211-Apr-09 17:22 
QuestionCompleting a mulit-page webform using WebClient Pin
front711-Apr-09 15:18
front711-Apr-09 15:18 
QuestionComboBoxes and DataGridViews... Pin
Illegal Operation1-Apr-09 13:37
Illegal Operation1-Apr-09 13:37 
AnswerRe: ComboBoxes and DataGridViews... Pin
Mycroft Holmes1-Apr-09 16:27
professionalMycroft Holmes1-Apr-09 16:27 
GeneralRe: ComboBoxes and DataGridViews... Pin
Illegal Operation1-Apr-09 17:15
Illegal Operation1-Apr-09 17:15 
AnswerRe: ComboBoxes and DataGridViews... Pin
a.hamidy1-Apr-09 18:42
a.hamidy1-Apr-09 18:42 
QuestionSelf Update .Net application with a web service. Pin
Member 34269361-Apr-09 13:11
Member 34269361-Apr-09 13:11 
AnswerRe: Self Update .Net application with a web service. Pin
Judah Gabriel Himango1-Apr-09 16:24
sponsorJudah Gabriel Himango1-Apr-09 16:24 
Questionrename file Pin
yogesh_softworld1231-Apr-09 10:06
yogesh_softworld1231-Apr-09 10:06 
AnswerRe: rename file Pin
Pete O'Hanlon1-Apr-09 10:14
mvePete O'Hanlon1-Apr-09 10:14 
AnswerRe: rename file Pin
Giorgi Dalakishvili1-Apr-09 10:18
mentorGiorgi Dalakishvili1-Apr-09 10:18 
AnswerRe: rename file Pin
Henry Minute1-Apr-09 10:24
Henry Minute1-Apr-09 10:24 
QuestionExtracting an embedded resource file issue. Pin
astroudjr1-Apr-09 9:18
astroudjr1-Apr-09 9:18 
AnswerRe: Extracting an embedded resource file issue. Pin
Giorgi Dalakishvili1-Apr-09 10:08
mentorGiorgi Dalakishvili1-Apr-09 10:08 
AnswerRe: Extracting an embedded resource file issue. Pin
0x3c01-Apr-09 10:34
0x3c01-Apr-09 10:34 

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.