PC Review


Reply
Thread Tools Rate Thread

Compact C# .NET -> How to add TreeView's nodes/items from threads?

 
 
EOS
Guest
Posts: n/a
 
      1st Dec 2005
Hi,

I am new to PDA development and my background is purely C/C++. Now I can get
the rought ideas on Compact C# .net for PDA development.

But I am having troubles on adding TreeView with nodes and items from
separate thread.

Hope someone can kindly share the lights with me. : )


 
Reply With Quote
 
 
 
 
=?Utf-8?B?YmFsbWVyY2g=?=
Guest
Posts: n/a
 
      1st Dec 2005
Look at the TreeView.Invoke() method. It will allow you to run another method
within the UI thread.

This if off the top of my head but:

private void UpdateTree(string nodeName)
{
treeView1.Nodes.Add(nodeName);
}

private void SomeMethodInAnotherThread()
{
treeView1.Invoke(UpdateTree, new object[] { "my node name" });
}

I utilize this myself when using a seperate class that runs in another
thread an raises events by allowing the person to specify a parent control
(which should be your form) when creating the class instance, that way my
OnEvent methods can launch the event in the UI thread without the host form
worrying about multithreading:

public event InstallEnd;
public void OnInstallEnd( InstallEventArgs e )
{
if ( this.InstallEnd == null )
return;

if ( parent == null )
this.InstallEnd( this, e );
else
this.parent.Invoke( InstallEnd, new object[] { this, e } );
}


Chris


"EOS" wrote:

> Hi,
>
> I am new to PDA development and my background is purely C/C++. Now I can get
> the rought ideas on Compact C# .net for PDA development.
>
> But I am having troubles on adding TreeView with nodes and items from
> separate thread.
>
> Hope someone can kindly share the lights with me. : )
>
>
>

 
Reply With Quote
 
EOS
Guest
Posts: n/a
 
      2nd Dec 2005
Thanks for the solution! : )

"balmerch" <(E-Mail Removed)> wrote in message
news:B100F4CE-2271-4207-8731-(E-Mail Removed)...
> Look at the TreeView.Invoke() method. It will allow you to run another
> method
> within the UI thread.
>
> This if off the top of my head but:
>
> private void UpdateTree(string nodeName)
> {
> treeView1.Nodes.Add(nodeName);
> }
>
> private void SomeMethodInAnotherThread()
> {
> treeView1.Invoke(UpdateTree, new object[] { "my node name" });
> }
>
> I utilize this myself when using a seperate class that runs in another
> thread an raises events by allowing the person to specify a parent control
> (which should be your form) when creating the class instance, that way my
> OnEvent methods can launch the event in the UI thread without the host
> form
> worrying about multithreading:
>
> public event InstallEnd;
> public void OnInstallEnd( InstallEventArgs e )
> {
> if ( this.InstallEnd == null )
> return;
>
> if ( parent == null )
> this.InstallEnd( this, e );
> else
> this.parent.Invoke( InstallEnd, new object[] { this, e } );
> }
>
>
> Chris
>
>
> "EOS" wrote:
>
>> Hi,
>>
>> I am new to PDA development and my background is purely C/C++. Now I can
>> get
>> the rought ideas on Compact C# .net for PDA development.
>>
>> But I am having troubles on adding TreeView with nodes and items from
>> separate thread.
>>
>> Hope someone can kindly share the lights with me. : )
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exemple needed to reorganize nodes(treeview) with mouse (change Nodes order) Marc R. Microsoft VB .NET 4 2nd Feb 2006 07:58 PM
How to add nodes into TreeView via Threads? EOS Microsoft C# .NET 12 13th Jan 2006 08:30 AM
Compact C# .NET -> How to add TreeView's nodes/items from threads? EOS Microsoft Dot NET 1 6th Dec 2005 11:50 PM
Treeview / Nodes =?Utf-8?B?TEM=?= Microsoft VB .NET 3 9th Nov 2004 11:42 AM
treeview to see all the nodes andreas Microsoft VB .NET 2 20th Jun 2004 02:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:03 AM.