Oscar
Oscar

Reputation: 75

C# windows forms not updating in method

Im trying to call some windows forms code (like setting label.visible = true in some event code, everything compiles ok, but form does not react to change! What could be the problem?

Problem is in lines:

labelNewCall.Visible = true;
timerNewCall.Enabled = true;

code : http://pastebin.com/gV28PN4P

also other code did not work, until i reordered some of it (order is not important but it did not work otherwise... )

Upvotes: 1

Views: 5277

Answers (4)

Ramesh Soni
Ramesh Soni

Reputation: 16077

Use invoke to access object in a windows forms/controls thread

Reference - http://www.dailycoding.com/...formscontrols_thread.aspx

Upvotes: 0

Russ Clarke
Russ Clarke

Reputation: 17909

You can also try a handy little method that you can place in your inner-loop:

Application.DoEvents();

Here's the MSDN write up:

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038820

This could be because the soundCapture_BufferThrown callback function is not run on the GUI thread. Read this post for more details about threading in WinForms.

Upvotes: 1

TcKs
TcKs

Reputation: 26632

Do you call this method in another than UI thread? If so, you should use Invoke and/or BeginInvoke method.

Look at article What's up with BeginInvoke?.

Upvotes: 1

Related Questions