Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I check if the datasource is writable? Pin
Edbert P28-Jun-06 19:01
Edbert P28-Jun-06 19:01 
GeneralRe: How can I check if the datasource is writable? Pin
AngryC28-Jun-06 19:39
AngryC28-Jun-06 19:39 
GeneralRe: How can I check if the datasource is writable? Pin
Robert Rohde28-Jun-06 20:01
Robert Rohde28-Jun-06 20:01 
GeneralRe: How can I check if the datasource is writable? Pin
Dave Kreskowiak29-Jun-06 1:31
mveDave Kreskowiak29-Jun-06 1:31 
QuestionModal Dialog help in C# [modified] Pin
McSmack28-Jun-06 14:57
McSmack28-Jun-06 14:57 
AnswerRe: Modal Dialog help in C# Pin
Alexander Wiseman28-Jun-06 15:41
Alexander Wiseman28-Jun-06 15:41 
QuestionRe: Modal Dialog help in C# [modified] Pin
Martin#28-Jun-06 19:34
Martin#28-Jun-06 19:34 
AnswerRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 5:39
Alexander Wiseman29-Jun-06 5:39 
Martin,

You won't be able to invoke a method with parameters if you are using the MethodInvoker delegate. Here is what MSDN says about MethodInvoker:

"MethodInvoker provides a simple delegate that is used to invoke a method with a void parameter list. This delegate can be used when making calls to a control's invoke method, or when you need a simple delegate but don't want to define one yourself."

Since MethodInvoker has a void parameter list, and since the function you specify must have the same parameters as the delegate in question, you won't be able to invoke a method with parameters using it.

In order to do this, you need to define your own delegate, which has the correct argument list. Let's suppose that the function you want to invoke by BeginInvoke has two parameters, a bool and a String, and that it looks like this:
public void ShowMyDialogBox(bool bTest, String message)
Now, you would define your delegate like this:
public delegate void MyDelegate(bool bTest, String message)
The name of the delegate is completely optional, as are the names of the parameters. We could have called the boolean parameter anything we want (e.g. bBoolParam) and we could have called the string parameter anything we want. Now we would invoke this as follows:
BeginInvoke(new MyDelegate(ShowMyDialogBox), new object [] { varToBeParam1, varToBeParam2 });
So now, if we put that together, our ShowMyDialogBox function would look something like this (assuming the scenario which McSmack had laid out):
public void ShowMyDialogBox(bool bTest, String message)
{
     if(this.InvokeRequired)
     {
          this.BeginInvoke(new this.MyDelegate(this.ShowMyDialogBox), new object [] { bTest, message });
          return;
     }
     // now we're on the main thread and can do processing as normal
     // the parameters also have their proper values
     ...
}
Hope that helps! Feel free to respond if you have any more questions about this, or if you do not understand something in the answer.

Sincerely,
Alexander Wiseman
GeneralRe: Modal Dialog help in C# [modified] Pin
Martin#29-Jun-06 6:11
Martin#29-Jun-06 6:11 
GeneralRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 6:30
Alexander Wiseman29-Jun-06 6:30 
GeneralRe: Modal Dialog help in C# Pin
Martin#29-Jun-06 6:41
Martin#29-Jun-06 6:41 
GeneralRe: Modal Dialog help in C# Pin
McSmack29-Jun-06 6:00
McSmack29-Jun-06 6:00 
QuestionRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 6:41
Alexander Wiseman29-Jun-06 6:41 
AnswerRe: Modal Dialog help in C# Pin
McSmack29-Jun-06 7:17
McSmack29-Jun-06 7:17 
QuestionRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 10:53
Alexander Wiseman29-Jun-06 10:53 
AnswerRe: Modal Dialog help in C# Pin
McSmack29-Jun-06 12:19
McSmack29-Jun-06 12:19 
GeneralRe: Modal Dialog help in C# Pin
Alexander Wiseman29-Jun-06 12:54
Alexander Wiseman29-Jun-06 12:54 
QuestionQuick button question [modified] Pin
Arkon94828-Jun-06 13:05
Arkon94828-Jun-06 13:05 
AnswerRe: Quick button question [modified] Pin
Mike Poz28-Jun-06 13:45
Mike Poz28-Jun-06 13:45 
QuestionExporting to SPSS issue Pin
Nader Elshehabi28-Jun-06 11:59
Nader Elshehabi28-Jun-06 11:59 
AnswerRe: Exporting to SPSS issue Pin
farquem828-Jun-06 16:01
farquem828-Jun-06 16:01 
GeneralRe: Exporting to SPSS issue Pin
Nader Elshehabi28-Jun-06 17:29
Nader Elshehabi28-Jun-06 17:29 
QuestionASP.net and Javascript Pin
Naji.A28-Jun-06 11:27
Naji.A28-Jun-06 11:27 
AnswerRe: ASP.net and Javascript Pin
Guffa28-Jun-06 12:06
Guffa28-Jun-06 12:06 
GeneralAny helpful hints? Pin
Naji.A28-Jun-06 12:12
Naji.A28-Jun-06 12:12 

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.