Okay, I'm sure there is a very simple solution to my problems here and I am
just too tired, but then again maybe not.
Here is an example of my code:
Dim Conn_Thrd as new system.threading.thread(addressof connecttoserver())
public sub connecttoserver()
'This works good
Treeview1.nodes.add("Test Node")
'This doesnt
clrnd()
'Neither does this
me.treeview1.invoke(clrnd)
end sub
'This ONLY works good when it is called inside the thread containing the
treeview1 control.
public function clrnd()
Treeview1.nodes.clear()
end sub
'This works good
Private sub Button1_click (...) handles button1.click
clrnd()
end sub
'This works good
Private sub Button2_click (...) handles button2.click
Conn_Thrd = new system.threading.thread(addressof connecttoserver())
Conn_Thrd.start()
end sub
Please help :)
Thanks,
Travis 6 1526
Travis,
You need to setup a Delegate then call the delegate function from your invoke. You're on the right track for sure.
look at: http://groups-beta.google.com/group/...ea5bacc8070fd3 www.projectthunder.com
-Calvin Luttrell
Projectthunder.com, Inc.
"thowle" <th****@brtc.net> wrote in message news:D8**********************************@microsof t.com... Okay, I'm sure there is a very simple solution to my problems here and I am just too tired, but then again maybe not. Here is an example of my code: Dim Conn_Thrd as new system.threading.thread(addressof connecttoserver()) public sub connecttoserver() 'This works good Treeview1.nodes.add("Test Node") 'This doesnt clrnd() 'Neither does this me.treeview1.invoke(clrnd) end sub 'This ONLY works good when it is called inside the thread containing the treeview1 control. public function clrnd() Treeview1.nodes.clear() end sub 'This works good Private sub Button1_click (...) handles button1.click clrnd() end sub 'This works good Private sub Button2_click (...) handles button2.click Conn_Thrd = new system.threading.thread(addressof connecttoserver()) Conn_Thrd.start() end sub Please help :) Thanks, Travis
thowle <th****@brtc.net> wrote: Okay, I'm sure there is a very simple solution to my problems here and I am just too tired, but then again maybe not.
See http://www.pobox.com/~skeet/csharp/t...winforms.shtml
Note that even when it *was* working for you, there's no guarantee
about it - you really shouldn't touch the UI at all from a non-UI
thread.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Okay, here is what I've done now. I created a class called "ConnectToServer"
in that class, it will fire off an event called "ConnectComplete"
In the mainform that contains GUI I have the sub to handle the event, and I
have it calling a function "GetServerList". However, it is still calling it
from inside the thread inwhich does not contain the GUI therefore it fails,
EVEN if i have a treeview1.invoke(GetServerList()).
How can I get this to work?
"thowle" wrote: Okay, I'm sure there is a very simple solution to my problems here and I am just too tired, but then again maybe not.
Here is an example of my code: Dim Conn_Thrd as new system.threading.thread(addressof connecttoserver())
public sub connecttoserver() 'This works good Treeview1.nodes.add("Test Node")
'This doesnt clrnd()
'Neither does this me.treeview1.invoke(clrnd) end sub
'This ONLY works good when it is called inside the thread containing the treeview1 control. public function clrnd() Treeview1.nodes.clear() end sub
'This works good Private sub Button1_click (...) handles button1.click clrnd() end sub
'This works good Private sub Button2_click (...) handles button2.click Conn_Thrd = new system.threading.thread(addressof connecttoserver()) Conn_Thrd.start() end sub
Please help :)
Thanks, Travis
thowle <th****@brtc.net> wrote: Okay, here is what I've done now. I created a class called "ConnectToServer"
in that class, it will fire off an event called "ConnectComplete"
In the mainform that contains GUI I have the sub to handle the event, and I have it calling a function "GetServerList". However, it is still calling it from inside the thread inwhich does not contain the GUI therefore it fails, EVEN if i have a treeview1.invoke(GetServerList()).
How can I get this to work?
You need to create a delegate from GetServerList, not call it directly.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Bacically, here is the concept of my application in a smaller form.
(Not all of it is complete)
private sub Button1_click(...) handles button1.click
AddHandler Connect.Connected, AddressOf Connected
Dim ConnectThread as new system.threading.thread(address of Connect)
ConnectThread.start()
end sub
Sub Connected()
treeview1.invoke(GetServerList())
End sub
Public function GetServerList()
....access database....
treeview1.nodes.add("Value")
....close recordset, and db conn....
end function
Public Class Connect
Public Event Connected()
....connect to server....
....yay, we are connected :)....
RaiseEvent Connected()
End class
Thats about it.
"Jon Skeet [C# MVP]" wrote: thowle <th****@brtc.net> wrote: Okay, here is what I've done now. I created a class called "ConnectToServer"
in that class, it will fire off an event called "ConnectComplete"
In the mainform that contains GUI I have the sub to handle the event, and I have it calling a function "GetServerList". However, it is still calling it from inside the thread inwhich does not contain the GUI therefore it fails, EVEN if i have a treeview1.invoke(GetServerList()).
How can I get this to work?
You need to create a delegate from GetServerList, not call it directly.
Could you post a short but complete program which demonstrates the problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Okay I got it working. and it was pretty wild :)
As Jon Skeet said, you must make a delegate for the GetServerList() function
as follows:
Delegate Function GetServerTView()
Public ReadOnly fnGetServerTView As GetServerTView
then:
Public Sub New()
fnGetServerTView = New GetServerTView(AddressOf Me.GetServerList)
end Sub
from here, you can call this from any thread as
treeview1.invoke(fnGetServerTView)!
Thx for help yall :)
"thowle" wrote: Bacically, here is the concept of my application in a smaller form. (Not all of it is complete)
private sub Button1_click(...) handles button1.click AddHandler Connect.Connected, AddressOf Connected
Dim ConnectThread as new system.threading.thread(address of Connect) ConnectThread.start() end sub
Sub Connected() treeview1.invoke(GetServerList()) End sub
Public function GetServerList() ....access database.... treeview1.nodes.add("Value") ....close recordset, and db conn.... end function Public Class Connect Public Event Connected() ....connect to server.... ....yay, we are connected :).... RaiseEvent Connected() End class
Thats about it.
"Jon Skeet [C# MVP]" wrote:
thowle <th****@brtc.net> wrote: Okay, here is what I've done now. I created a class called "ConnectToServer"
in that class, it will fire off an event called "ConnectComplete"
In the mainform that contains GUI I have the sub to handle the event, and I have it calling a function "GetServerList". However, it is still calling it from inside the thread inwhich does not contain the GUI therefore it fails, EVEN if i have a treeview1.invoke(GetServerList()).
How can I get this to work?
You need to create a delegate from GetServerList, not call it directly.
Could you post a short but complete program which demonstrates the problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Yudkin |
last post by:
The documentation is unclear (at least to me) on the permissibility of
accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003,
with separate transactions scope, from separate...
|
by: Robert Zurer |
last post by:
Can anyone suggest the best book or part of a book on this subject. I'm
looking for an in-depth treatment with examples in C#
TIA
Robert Zurer
robert@zurer.com
|
by: Michael C |
last post by:
Hello
Can someone please tell me what I'm doing wrong? I'm writing an application
that should be using callbacks to perform asynchronous calls to the Win32
API. Problem is it never reaches my...
|
by: sarge |
last post by:
I would like to know how to perform simple multithreading.
I had created a simple form to test out if I was multithreading
properly, but got buggy results. Sometime the whole thig would lock
up...
|
by: shonend |
last post by:
**** sorry about the length of the message. If you can't read the
whole thing and still willing to help, read the last 2 paragraphs where
the main problem is described. The introduction story is...
|
by: Multithreading problem in vb.net |
last post by:
Greetings,
I am new to multithreading and I am trying to implement it in my app.
This application is distributed application which needs to refresh
every say 5 secs to show some activities in...
|
by: Michael |
last post by:
Hi,
I am trying to create a multithreaded VB 2005 application which attempts to
create a new thread per Domain Controller (DC) in my environment. Each thread
connects to its allocated DC and...
|
by: denis.cornehl |
last post by:
Hi,
I have an unusual Problem with DB2.
It is DB2 Version 7 and Fixpack 13 under Windows.
We have written an application server which is accessing db2 via c++
and the cli interface.
We used...
|
by: Pradnya Patil |
last post by:
hi ,
I am trying to draw ' html div-tag ' on the screen which will
resemble a rectangle through vb.net code.
I want it to be drawn faster...so I introduced multithreading
using Threadpool. I...
|
by: Ray |
last post by:
Hello,
Greetings! I'm looking for a solid C++ multithreading book. Can you
recommend one? I don't think I've seen a multithreading C++ book that
everybody thinks is good (like Effective C++ or...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |