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
4
votes
1 answer

Why does Dispatcher.BeginInvoke unwrap TargetInvocationException for ThreadStart but not for Action?

Consider the following two applications: 1: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.Dispatcher.UnhandledException += Dispatcher_UnhandledException; } void…
floele
  • 3,668
  • 4
  • 35
  • 51
4
votes
4 answers

Problems related to showing MessageBox from non-GUI threads

I'm working on a heavily data-bound Win.Forms application where I've found some strange behavior. The app has separate I/O threads receiving updates through asynchronous web-requests which it then sends to the main/GUI thread for processing and…
Hans Løken
  • 407
  • 1
  • 6
  • 15
4
votes
1 answer

Does calling an async method within BeginInvoke() spawn a 'new' thread?

'New' meaning from a thread pool. Given the example below, my assumptions are: Main method executes on one thread (eg. thread 1) BeginInvoke uses available thread in pool to execute AsyncDemo.TestMethod (thread 2) An async method call, eg…
4
votes
0 answers

C# Adding to BindingList causes Operation is not valid due to the current state of the object

I'm working on a program that is adding to a couple of BindingLists in 2 separate threads. The action of adding to these BindingLists adds rows to 2 separate DatagridViews. As I want both DataGridViews to update concurrently, both threads are…
4
votes
2 answers

Why use BeginInvoke here?

I am looking into someone else's code and do not have much experience with anything to do with multi-threading. I came across this line of code: BeginInvoke((MethodInvoker)delegate() { btnCalibrate.PerformClick(); }); I was wondering why do this…
Aishwar
  • 9,284
  • 10
  • 59
  • 80
4
votes
1 answer

Update control from secondary thread: is Invoke performance critical?

A c# application I’m developing consists essentially of performing operations on images coming from a camera and printing them on a picturebox. It has a library written in c++ that retrieves images from a webcam (imgcam), and makes copies of them…
Giuseppe Dini
  • 762
  • 7
  • 19
4
votes
2 answers

WPF Dispatcher on non-UI thread

According to MSDN, Dispatcher provides services for managing the queue of work items for a thread. A simple question. I want to use Dispatcher just for that: as a queue of work items (posted via Dispatcher.BeginInvoke) which my background thread…
avo
  • 10,101
  • 13
  • 53
  • 81
3
votes
2 answers

Unable to upgrade to Microsoft SQL Server2008 R2 RTM - Express with Advanced Services

I am trying to upgrade my current Express edition to Express with Advanced Services for supporting full-text search. The current system setup is: OS version: Windows server 2008 R2 web server 64 bit SQL Server 2008 R2 Express, SP1,…
user1289811
  • 81
  • 1
  • 4
3
votes
1 answer

Windows Phone: how to tell when Deployment.Current.Dispatcher.BeginInvoke has completed?

I'm trying to make the UI of a page in a WP7 application more responsive by putting the data loading portion into a background thread rather than running in the foreground when the page loads. The thread code essentially works through some data and…
Philip Colmer
  • 1,426
  • 2
  • 17
  • 30
3
votes
3 answers

Reasons that Control.BeginInvoke would not execute a delegate?

Overview Are there explanations for Control.BeginInvoke() to not execute a delegate that it is passed? Code Sample We have adopted the following pattern in our Winforms applications to safely execute UI releated work on the UI thread: private…
Chris Scott
  • 1,721
  • 14
  • 27
3
votes
3 answers

When using Parallel BeginInvoke is working while Invoke is not - c# 4.0

When i use invoke inside AddListBoxItem function as seen below software become unreponsive and frozen but if i use BeginInvoke it works. Why is that happening ? visual studio 2010 , C# 4.0 private void button2_Click(object sender, EventArgs e) { …
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
3
votes
3 answers

Control.Invoke() and Control.BeginInvoke() - Where are the past parameters stored? How is it disposed?

I have done a lot of reading about Control.Invoke and Control.BeginInvoke and understand that Invoke is like SendMessage() and BeginInvoke is like PostMessage(), but I do not understand where the parameter list passed via new object[] { arg, arg,…
CCS
  • 299
  • 4
  • 13
3
votes
2 answers

Socket programming : Can asynchronous methods of send and read ensure the order of data?

If I call the c# asynchronous method continuously as shown below: socket.BeginSend(data1, 0, data1.Length, 0, new AsyncCallback(SendCallback1), handler); socket.BeginSend(data2, 0, data2.Length, 0, new AsyncCallback(SendCallback2),…
atomd
  • 558
  • 1
  • 5
  • 11
3
votes
1 answer

When should I use UdpClient.BeginReceive? When should I use UdpClient.Receive on a background thread?

Essentially, what are the differences between these beyond the obvious? When should I use which form? class What { public Go() { Thread thread = new Thread(new ThreadStart(Go2)); thread.Background = true; …
Ansis Māliņš
  • 1,684
  • 15
  • 35
3
votes
3 answers

When is invoke required on GUI objects?

Using C# Windows.Forms, do the methods Invalidate(), Refresh(), etc. have to be run on the main/GUI thread (require Invoke/BeginInvoke)? How about changes to members of a GUI object such as adding/deleting Points or changing the Color of a Series…
Jess
  • 2,991
  • 3
  • 27
  • 40