| | |
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 algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






