By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,470 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,470 IT Pros & Developers. It's quick & easy.

Reading access component from other thread.(thread stopped excepti

P: n/a
I have some unreasonable issue while reading access component from other
thread.
I have a Form class which includes TreeView, this tree view includes some
TreeNodes , lets say 2 .
In my Form class I define an arraylist which include reference to those
TreeNodes.

ArayList myTNodesPackage (define ...)
myTNodesPackage.Add….

Now I have:
myTNodesPackage[0] = treeNode1
myTNodesPackage[2] = treeNode2
I create tread and start it as following:
// ExecuteThread thread Class
m_ExecuteThread = new ExecuteThread(this);
this.ExecuteCommandsThread = new Thread(new
ThreadStart(m_ExecuteThread.Go_Execution_AllTests) );
this.ExecuteCommandsThread.Start();

In my thread Go_Execution_AllTests function start running and do something
until the following line code:

rootNode = (TreeNode)this.myForm.myTNodesPackage [0];
Now I can see that this access cause somtiong since my debug start respond
sloly.I see that rootNode.Text is OK but all other properties are not
available "error : cannot obtain value".

If I continue debugging the following code I will get an exception "Thread
was being stoped." .
if(rootNode.Checked==false)

Any one can explain me why ? and what should I do ?
Why thread stopped ?
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
=?Utf-8?B?W1lvc2ld?= <Yo**@discussions.microsoft.com> wrote in
news:40**********************************@microsof t.com:
I have some unreasonable issue while reading access component
from other thread.
I have a Form class which includes TreeView, this tree view
includes some TreeNodes , lets say 2 .
In my Form class I define an arraylist which include reference
to those TreeNodes.

ArayList myTNodesPackage (define ...)
myTNodesPackage.Add….

Now I have:
myTNodesPackage[0] = treeNode1
myTNodesPackage[2] = treeNode2
I create tread and start it as following:
// ExecuteThread thread Class
m_ExecuteThread = new ExecuteThread(this);
this.ExecuteCommandsThread = new Thread(new
ThreadStart(m_ExecuteThread.Go_Execution_AllTests) );
this.ExecuteCommandsThread.Start();

In my thread Go_Execution_AllTests function start running and do
something until the following line code:

rootNode = (TreeNode)this.myForm.myTNodesPackage [0];
Now I can see that this access cause somtiong since my debug
start respond sloly.I see that rootNode.Text is OK but all other
properties are not available "error : cannot obtain value".

If I continue debugging the following code I will get an
exception "Thread was being stoped." .
if(rootNode.Checked==false)

Any one can explain me why ? and what should I do ?
Why thread stopped ?


Yosi,

Only the form's thread, or a thread it starts thru Invoke or BeginInvoke,
can modify a visual control.

http://msdn.microsoft.com/library/de...ms06112002.asp
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 17 '05 #2

P: n/a
I know that read access is avialable from another threades but write is not
accessable.
And also I know that this in framewark 2 not 1.1.
thanks for helping.

"Chris R. Timmons" wrote:
=?Utf-8?B?W1lvc2ld?= <Yo**@discussions.microsoft.com> wrote in
news:40**********************************@microsof t.com:
I have some unreasonable issue while reading access component
from other thread.
I have a Form class which includes TreeView, this tree view
includes some TreeNodes , lets say 2 .
In my Form class I define an arraylist which include reference
to those TreeNodes.

ArayList myTNodesPackage (define ...)
myTNodesPackage.Add….

Now I have:
myTNodesPackage[0] = treeNode1
myTNodesPackage[2] = treeNode2
I create tread and start it as following:
// ExecuteThread thread Class
m_ExecuteThread = new ExecuteThread(this);
this.ExecuteCommandsThread = new Thread(new
ThreadStart(m_ExecuteThread.Go_Execution_AllTests) );
this.ExecuteCommandsThread.Start();

In my thread Go_Execution_AllTests function start running and do
something until the following line code:

rootNode = (TreeNode)this.myForm.myTNodesPackage [0];
Now I can see that this access cause somtiong since my debug
start respond sloly.I see that rootNode.Text is OK but all other
properties are not available "error : cannot obtain value".

If I continue debugging the following code I will get an
exception "Thread was being stoped." .
if(rootNode.Checked==false)

Any one can explain me why ? and what should I do ?
Why thread stopped ?


Yosi,

Only the form's thread, or a thread it starts thru Invoke or BeginInvoke,
can modify a visual control.

http://msdn.microsoft.com/library/de...ms06112002.asp
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Nov 17 '05 #3

P: n/a
NO, you should not "access" UI elements (except menu's) from another thread
than the thread that created the UI elements.
And here "access" means reading and writing! And it doesn't matter wheter
you are using 1.1 or 2.0 it's not due to .NET it's imposed by Windows
itself.
Willy.

"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
I know that read access is avialable from another threades but write is not
accessable.
And also I know that this in framewark 2 not 1.1.
thanks for helping.

"Chris R. Timmons" wrote:
=?Utf-8?B?W1lvc2ld?= <Yo**@discussions.microsoft.com> wrote in
news:40**********************************@microsof t.com:
> I have some unreasonable issue while reading access component
> from other thread.
> I have a Form class which includes TreeView, this tree view
> includes some TreeNodes , lets say 2 .
> In my Form class I define an arraylist which include reference
> to those TreeNodes.
>
> ArayList myTNodesPackage (define ...)
> myTNodesPackage.Add….
>
> Now I have:
> myTNodesPackage[0] = treeNode1
> myTNodesPackage[2] = treeNode2
> I create tread and start it as following:
> // ExecuteThread thread Class
> m_ExecuteThread = new ExecuteThread(this);
> this.ExecuteCommandsThread = new Thread(new
> ThreadStart(m_ExecuteThread.Go_Execution_AllTests) );
> this.ExecuteCommandsThread.Start();
>
> In my thread Go_Execution_AllTests function start running and do
> something until the following line code:
>
> rootNode = (TreeNode)this.myForm.myTNodesPackage [0];
> Now I can see that this access cause somtiong since my debug
> start respond sloly.I see that rootNode.Text is OK but all other
> properties are not available "error : cannot obtain value".
>
> If I continue debugging the following code I will get an
> exception "Thread was being stoped." .
> if(rootNode.Checked==false)
>
> Any one can explain me why ? and what should I do ?
> Why thread stopped ?


Yosi,

Only the form's thread, or a thread it starts thru Invoke or BeginInvoke,
can modify a visual control.
http://msdn.microsoft.com/library/de...ms06112002.asp
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.