Questions tagged [begininvoke]

The Windows-specific Dispatcher.BeginInvoke API method

The Windows-specific Dispatcher.BeginInvoke API method.

This API call asynchronously runs a delegate on the dispatcher-associated thread.

280 questions
11
votes
2 answers

Where are CLR-defined methods like [delegate].BeginInvoke documented?

[EDIT, Completely rephrased:] Seems like my question was poorly worded indeed, and poorly received too. So I hope that this complete rephrasing helps... MSDN tells clearly specifies: Control.BeginInvoke() Executes a delegate on the thread that the…
Adam
  • 637
  • 1
  • 8
  • 21
10
votes
2 answers

Winforms to WPF conversion: BeginInvoke to what?

Here's my old code from WinForms: private void ValueChanged(double inValue1, double inValue2) { //only manual mode for this driver, so that's easy. if (ValueLabel.InvokeRequired) { ValueLabel.Invoke(new…
mmr
  • 14,781
  • 29
  • 95
  • 145
10
votes
3 answers

Call BeginInvoke on MulticastDelegate?

According to Jon Skeet, "You can only call BeginInvoke on a delegate which has a single target invocation." Why is that? What's the real reason? Note: For clarification (and because I made this mistake), I am talking about the BeginInvoke on…
richard
  • 12,263
  • 23
  • 95
  • 151
10
votes
2 answers

Dispatcher.Invoke with anonymous delegate works in Silverlight but not WPF

In Silverlight 4 I have a custom service class which has an asynchronous Completed event. Inside the Completed event I take the returned data and invoke a populate method via something like this: private void service_Completed(object sender,…
9
votes
4 answers

Do I need to call EndInvoke after a timeout?

On a web page, I am calling a third party who does not allow me to set timeout programatically. I call BeginInvoke and use the AsyncWaitHandle.WaitOne to wait a specified amount of time. If the call times out, I move on and forget about the thread…
Chad
  • 551
  • 2
  • 7
  • 14
9
votes
3 answers

Does BeginInvoke() run a separate thread?

In my WPF application, I want to do some work in a non-UI thread so as to avoid the UI from become not-responding. For that I did this: var caller = new AsyncMethodCaller(this.SetPatternType); caller.BeginInvoke(_patterns, null, null); And…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
9
votes
3 answers

What should be passed for BeginInvoke's @object parameter?

I have an event delegate that is defined as follows: public delegate void CallbackDelegate(Data data); public event CallbackDelegate OnDataComplete; I raise the event asynchronously: // Raise the OnDataComplete event OnDataComplete.BeginInvoke(new…
Kiril
  • 39,672
  • 31
  • 167
  • 226
9
votes
1 answer

Understanding Thread/BeginInvoke? [beginner]

Consider the code: class Work { public void DoStuff(string s) { Console.WriteLine(s); // .. whatever } } class Master { private readonly Work work = new Work(); public void Execute() { string hello =…
Moberg
  • 783
  • 1
  • 8
  • 17
8
votes
3 answers

How to Unit Test BeginInvoke on an Action

I am looking for a way to test BeginInvoke on an Action method, since the method runs on a background thread there is no way of knowing when it actually completes or calls callback method. I am looking for a way to keep my test wait until the…
skjagini
  • 3,142
  • 5
  • 34
  • 63
8
votes
3 answers

Delegate.BeginInvoke Delay

Sometimes when Delegate.BeginInvoke is invoked, it takes more than one second to execute the delegate method. What could be the reasons for the delay? I get this issue 1 or 2 times a day in an application which runs continuosly. Please help…
Maanu
  • 5,093
  • 11
  • 59
  • 82
8
votes
7 answers

Why is my BeginInvoke method not async?

In order to avoid freezing of GUI, I wanted to run method connecting to DB asynchronously. Therefore I have written this: DelegatLoginu dl = ConnectDB; IAsyncResult ar = dl.BeginInvoke(null, null); var result = (bool)dl.EndInvoke(ar); But it is…
Petr
  • 7,787
  • 14
  • 44
  • 53
7
votes
2 answers

Invoke of an EventHandler

I have the following EventHandler: private EventHandler _myEventHandler; public event EventHandler MyEvent { add { _myEventHandler += value; } remove { _myEventHandler -= value; } } Could somebody explain the…
WaltiD
  • 1,932
  • 2
  • 23
  • 25
7
votes
3 answers

Asynchronous Invoking - Is EndInvoke required?

Possible Duplicates: Must every BeginInvoke be followed by an EndInvoke? Is EndInvoke() optional, sort-of optional, or definitely not optional? I've got a multithreaded application, and one of the secondary threads needs to get some code to…
William Lawn Stewart
  • 1,205
  • 1
  • 12
  • 23
7
votes
3 answers

A threading problem where mono hangs and MS.Net doesn't

I'm testing my app with mono in prevision of a Linux port, and I have a threading problem. I initially considered pasting 3000 code lines here, but finally I've devised a small minimal example ;) You have a form with a button (poetically named…
Clément
  • 12,299
  • 15
  • 75
  • 115
7
votes
1 answer

Pass multiple parameters to BeginInvoke()

I have simple (as i think) logic. public static void NotifyAboutNewJob(int jobId, bool forceSending = false) { Action notifier = SendAppleNotifications; notifier.BeginInvoke(jobId, null, null); } Method SendAppleNotifications…
demo
  • 6,038
  • 19
  • 75
  • 149
1
2
3
18 19