Click here to Skip to main content
15,879,096 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to copy a picture??? Pin
Wjousts20-Jan-06 9:26
Wjousts20-Jan-06 9:26 
AnswerRe: How to copy a picture??? Pin
CodyGen20-Jan-06 9:44
CodyGen20-Jan-06 9:44 
AnswerRe: How to copy a picture??? Pin
CrazyDragon638420-Jan-06 23:23
CrazyDragon638420-Jan-06 23:23 
GeneralRe: How to copy a picture??? Pin
CodyGen21-Jan-06 3:45
CodyGen21-Jan-06 3:45 
QuestionDataGridViewColumn DefaultCellStyle help Pin
Kasdoffe20-Jan-06 7:59
Kasdoffe20-Jan-06 7:59 
QuestionCalling Visual Basic .net class object in C# Pin
idreesbadshah20-Jan-06 7:33
idreesbadshah20-Jan-06 7:33 
AnswerRe: Calling Visual Basic .net class object in C# Pin
Dave Kreskowiak20-Jan-06 7:39
mveDave Kreskowiak20-Jan-06 7:39 
Questionwhy can't i start/stop separate threads inside of same block? Pin
WetRivrRat20-Jan-06 5:47
WetRivrRat20-Jan-06 5:47 
hey everyone...
i've probably missed something very important, and just don't know it.
the reason: i'm trying to populate 2 treeviews from 2 separate threads with separate data in each, both trees are pretty slow to load so i need the threads, else i lock up the ui for about 10sec. I also have to refresh the trees throughout the progress so i've had to build the threads the way i have so i can access it later.

the problem: if i try to invoke both threads in the same form_load block i end up with 2 trees with the same data. if i invoke them separately (comment one or the other out) i have proven that the code works properly for both, so it leads me to believe that i've either done something terribly wrong or i just can't do what i'm trying to do........

any ideas?

here is the code:

Thread PcTree, pclist,EmpTree,emplist;

                       MethodInvoker CallCompList, CallEmpList;



                       private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)

                       {



                                   //                                  pclist = new Thread(new ThreadStart(initializePcTree));

                                   //                                  pclist.Start();

                                   //                                  emplist = new Thread(new ThreadStart(initializeEmpTree));

                                   //                                  emplist.Start();

                                   switch (tabControl1.SelectedIndex)

                                   {

                                               case 0:

                                                           initializePcTree();

                                                           break;

                                               case 4:

                                                           initializeEmpTree();

                                                           break;
                                   }

                       }



                       private void initializePcTree()

                       {

                                   PcTree = new Thread(new ThreadStart(PopComputerList));

                                   PcTree.IsBackground = true;

                                   PcTree.Name = "PcTree";

                                   PcTree.Start();

                       }

                       private void initializeEmpTree()

                       {

                                   EmpTree = new Thread(new ThreadStart(PopEmpList));

                                   EmpTree.IsBackground = true;

                                   EmpTree.Name = "EmpTree";

                                   EmpTree.Start();

                       }



                       private void PopComputerList()

                       {

                                   CallCompList = new MethodInvoker(CompList);

                                   de = new DirectoryEntry("LDAP://~.com");

                                   ds = new DirectorySearcher(de);

                                   ds.Filter = ("(~)");

                                   this.BeginInvoke(CallCompList);

                       }

                       private void PopEmpList()

                       {

                                   CallEmpList = new MethodInvoker(EmpList);

                                   de = new DirectoryEntry("LDAP://~.com");

                                   ds = new DirectorySearcher(de);

                                   ds.Filter = ("(~)");

                                   this.BeginInvoke(CallEmpList);

                       }

                       private void newCompList()

                       {

                                   CompList();

                       }

                       private void newEmpList()

                       {

                                   EmpList();

                       }

                       private void CompList()

                       {

                                   statusBarPanel1.Text = "Please Wait While We Update the List";

                                   PCmonitorTree.Nodes.Clear();

                                   ParentNode = new TreeNode("TopNode");

                                   PCmonitorTree.Nodes.Add(ParentNode);

                                   foreach(SearchResult sr in ds.FindAll())

                                   {

                                               TreeNode PCnode = new TreeNode();

                                               PCnode.Text = sr.GetDirectoryEntry().Name.Split("=".ToCharArray())[1].ToString();

                                               ParentNode.Nodes.Add(PCnode);

                                               TreeNode PCnode1 = new TreeNode();

                                               PCnode1.Text = "PC - " +sr.GetDirectoryEntry().Name.Split("=".ToCharArray())[1].ToString();

                                               PCnode1.Tag = sr.GetDirectoryEntry().Name.Split("=".ToCharArray())[1].ToString();



                                               PCnode.Nodes.Add(PCnode1);

                                               PCmonitorTree.Sorted = true;



                                   }



                                   PCmonitorTree.ExpandAll();

                                   t = ParentNode;

                                   PCmonitorTree.SelectedNode = t;

                                   //Loaded();





                                   statusBarPanel1.Text = "Ready";

                       }



                       private void EmpList()

                       {

                                   statusBarPanel1.Text = "Please Wait While We Update the List";

                                   empTree.Nodes.Clear();

                                   TreeNode ParentNode = new TreeNode("TopNode");

                                   empTree.Nodes.Add(ParentNode);



                                   foreach(SearchResult sr in ds.FindAll())

                                   {

                                               DirectoryEntry DE = sr.GetDirectoryEntry();

                                               TreeNode empnode = new TreeNode();

                                               empnode.Text = sr.GetDirectoryEntry().Name.Split("=".ToCharArray())[1].ToString();

                                               empnode.Tag = sr.GetDirectoryEntry().Name.Split("=".ToCharArray())[1].ToString();

                                               ParentNode.Nodes.Add(empnode);

                                               empTree.ExpandAll();

                                               empTree.Sorted = true;

                                   }

                                   t=ParentNode;

                                   empTree.SelectedNode = t;



                                   statusBarPanel1.Text = "Ready";
                       }



string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";


Why is common sense such an un-common comodity?
AnswerRe: why can't i start/stop separate threads inside of same block? Pin
Le centriste20-Jan-06 6:03
Le centriste20-Jan-06 6:03 
AnswerRe: why can't i start/stop separate threads inside of same block? Pin
Dave Kreskowiak20-Jan-06 6:25
mveDave Kreskowiak20-Jan-06 6:25 
GeneralRe: why can't i start/stop separate threads inside of same block? Pin
WetRivrRat20-Jan-06 7:50
WetRivrRat20-Jan-06 7:50 
QuestionError handling - which is preferrable? Pin
Judah Gabriel Himango20-Jan-06 5:25
sponsorJudah Gabriel Himango20-Jan-06 5:25 
AnswerRe: Error handling - which is preferrable? Pin
Colin Angus Mackay20-Jan-06 5:34
Colin Angus Mackay20-Jan-06 5:34 
GeneralRe: Error handling - which is preferrable? Pin
Werdna20-Jan-06 6:14
Werdna20-Jan-06 6:14 
GeneralRe: Error handling - which is preferrable? Pin
Judah Gabriel Himango20-Jan-06 9:56
sponsorJudah Gabriel Himango20-Jan-06 9:56 
QuestiondataGrid & first row selection Pin
moonangel_bio20-Jan-06 5:00
moonangel_bio20-Jan-06 5:00 
AnswerRe: dataGrid & first row selection Pin
CodyGen20-Jan-06 5:42
CodyGen20-Jan-06 5:42 
AnswerRe: dataGrid & first row selection Pin
Drew McGhie20-Jan-06 9:22
Drew McGhie20-Jan-06 9:22 
GeneralRe: dataGrid & first row selection Pin
moonangel_bio21-Jan-06 1:34
moonangel_bio21-Jan-06 1:34 
QuestionClearing the DataTable Pin
dvsr20-Jan-06 4:21
dvsr20-Jan-06 4:21 
QuestionPower Point from C# code Pin
Bested20-Jan-06 2:57
Bested20-Jan-06 2:57 
QuestionHow to use Bass.Net.dll Pin
Divyang Mithaiwala20-Jan-06 2:41
Divyang Mithaiwala20-Jan-06 2:41 
AnswerRe: How to use Bass.Net.dll Pin
Colin Angus Mackay20-Jan-06 5:36
Colin Angus Mackay20-Jan-06 5:36 
GeneralRe: How to use Bass.Net.dll Pin
Divyang Mithaiwala20-Jan-06 6:25
Divyang Mithaiwala20-Jan-06 6:25 
GeneralRe: How to use Bass.Net.dll Pin
Dave Kreskowiak20-Jan-06 7:01
mveDave Kreskowiak20-Jan-06 7:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.