472,791 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

calling a delegate in a another thread (compact .NET)

Me again.... second time I type this - the post did not work the first
time...

Similar question as last time, but another problem:
I am running a CE.Net Application and I want to show a small
borderless dialog which shows an animation, that shows, that the
application is still doing something. So far it works until I want to
close the dialog. The dialog has a delegate that I want to invoke,
which will close it. But I run into a System.ArgumentException with
additional Information 'ArgumentException' if I want to invoke the
delegate.

Here is what I am trying to do:
--------------------------------------------------
namespace MyNamespace
{
public delegate void CloseDialogDelegate();

public class MyDialog : System.Windows.Forms.Form
{
public CloseDialogDelegate m_CloseDialog;
public MyDialog()
{
this.m_CloseDialog = new CloseDialogDelegate(CloseDialog);
...
}
...
private void CloseDialog()
{
this.Close();
}
}

public class MainForm : System.Windows.Forms.Form
{
private MyDialog m_MyDialog;
private Thread m_MyDialogThread;
...
private void MyDialogThreadFunc()
{
Application.Run(this.m_MyDialog = new MyDialog());
}
private void OpenMyDialog()
{
this.m_MyDialogThread = new Thread(new
ThreadStart(MyDialogThreadFunc));
this.m_MyDialogThread.Start();
}
private void CloseMyDialog()
{
// here happens the System.ArgumentException
this.m_MyDialog.Invoke(this.m_MyDialog.m_CloseDial og);
}
...
private void DoSomeWork()
{
this.OpenMyDialog();
// Do some work, including excessive
// UI stuff for this form
...
this.CloseMyDialog();
}
}
}
-----------------------------------------------------------

I am confused... I do not even pass arguments to the other thread, the
delegate has no arguments and CF.Net does not support an Invoke with
arguments...

What happens here?
Alexander
Nov 16 '05 #1
3 10128
Alexander <jo*******@gmx.de> wrote:
Me again.... second time I type this - the post did not work the first
time...

Similar question as last time, but another problem:
I am running a CE.Net Application and I want to show a small
borderless dialog which shows an animation, that shows, that the
application is still doing something. So far it works until I want to
close the dialog. The dialog has a delegate that I want to invoke,
which will close it. But I run into a System.ArgumentException with
additional Information 'ArgumentException' if I want to invoke the
delegate.


IIRC, you can only call Control.Invoke with EventHandler delegates in
the Compact Framework.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Jon,

I don't believe this is true. The only thing about calling
Control.Invoke with EventHandler delegates is that it will not honor the
parameters that you pass in. Rather, it will pass the control that Invoke
is called on, and EventArgs.Empty (it does this as an optimization, I
believe).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Alexander <jo*******@gmx.de> wrote:
Me again.... second time I type this - the post did not work the first
time...

Similar question as last time, but another problem:
I am running a CE.Net Application and I want to show a small
borderless dialog which shows an animation, that shows, that the
application is still doing something. So far it works until I want to
close the dialog. The dialog has a delegate that I want to invoke,
which will close it. But I run into a System.ArgumentException with
additional Information 'ArgumentException' if I want to invoke the
delegate.


IIRC, you can only call Control.Invoke with EventHandler delegates in
the Compact Framework.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
Nicholas Paldino [.NET/C# MVP] <mv*@spam.guard.caspershouse.com> wrote:
I don't believe this is true. The only thing about calling
Control.Invoke with EventHandler delegates is that it will not honor the
parameters that you pass in.


Well, that is indeed true. However, there are other things which make
it special:

1) It's more efficient than using other delegates on the desktop
framework
2) It's all that's supported on the Compact Framework.

And yes, this means that in the Compact Framework, you basically can't
invoke delegates with useful arguments. You have to put the state in
some shared area of data. It sucks :(

See
http://msdn.microsoft.com/mobility/p...netcf/faq/defa
ult.aspx#7.10

If you have a working example of calilng Control.Invoke with something
other than an EventHandler in the Compact Framework, I'd be very
interested.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marina | last post by:
Hi, we have an app, that executes jobs submitted from an outside application. It executes them asynchronusly, by creating a delegate to the method that can run the job, and calling BeginInvoke on...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
4
by: Dean Bortell | last post by:
I am writing a multi-threaded program with a worker thread. I want the rich text box to auto scroll down as the text is added. Here is what I want to happen: From the worker thread: 1. Add the...
1
by: Alexander | last post by:
Me again... ;) I am running a small borderless dialog in a seperate thread, that shows a small animation and I want to signal it to close itself. But I am running in a System.ArgumentException...
1
by: Bill Soudan | last post by:
Hi all, I'm a MS/.NET newbie, diving right into CLR interop. I've worked through the various issues foreign to me as a UNIX guy: multiple heap issues because I was linking to different CRT...
3
by: kplkumar | last post by:
I want to call a method passing a parameter. I want to do this call on a seperate thread. For example, public class Foo { public static void FooSend(Message message) { // Start a seperate...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
1
by: SAL | last post by:
Hello, I'm developing this remoting app (.net 2.0) and I need to bring the server app's form to the front often. Since you can not do cross-thread communication on a form or control without using...
15
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a...
9
by: Pubs | last post by:
Hi all, I want to call a function with some intial parameters with in a thread. At the end of the function execution it should return a value to the caller. Caller is outside the thread. ...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.