| | |
Callbacks problems
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 489
Reputation:
Solved Threads: 5
Hey guys,
I've got a multithreaded application. The GUI runs on its own thread whilst a background worker thread will get invovked later on. Now the problem occurs when the bakground thread trys to manipulate the GUI thread.
Solution is a callback using invokeRequired.
But this fails when its running... With error of
switchPanels is a method declared to take an int has an agrument.
Confused. Can anyone shread any light onto this problem?
Thanks guys...
I've got a multithreaded application. The GUI runs on its own thread whilst a background worker thread will get invovked later on. Now the problem occurs when the bakground thread trys to manipulate the GUI thread.
Solution is a callback using invokeRequired.
C# Syntax (Toggle Plain Text)
public void ThreadProcSafe2(String text) { if (this.m_AllKnownDevicesFrm.InvokeRequired) { // It's on a different thread, so use Invoke. SetTextCallback3 d = new SetTextCallback3(switchPanels); this.Invoke(d, new object[] {1} ); } else { switchPanels(1); } }
But this fails when its running... With error of
•
•
•
•
"invalid parameter"
Confused. Can anyone shread any light onto this problem?
Thanks guys...
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
try this
its unclear why you are using string text as a parameter if its not being passed on, but here it is
its unclear why you are using string text as a parameter if its not being passed on, but here it is
C# Syntax (Toggle Plain Text)
void delegate textCallback(string text); public void ThreadProcSafe2(String text) { if (this.m_AllKnownDevicesFrm.InvokeRequired) { this.m_AllKnownDevicesFrm.Invoke(new textCallback(ThreadProcSafe2), text); } else { switchPanels(1); } }
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
Other Threads in the C# Forum
- Previous Thread: Cannot open 2 or more outlook contact detail
- Next Thread: Totaling and averaging column in datagridview
| Thread Tools | Search this Thread |
.net access activedirectory ado.net algorithm array barchart bitmap box broadcast c# check checkbox client combobox contorl control conversion csharp custom database datagrid datagridview dataset datetime degrees deployment development disabled displayingopenforms draganddrop drawing editing editor encryption enum event excel file form format forms ftp function gdi+ httpwebrequest i18n image imageprocessing index index-error input install java label list listbox mandelbrot math mathematics mouseclick mysql operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remoting richtextbox rows server setup sleep socket sql statistics stream string table text textbox thread time timer update user usercontrol validation visualstudio webbrowser windows winforms wpf xml






