Note that there are some explanatory texts on larger screens.

plurals
  1. POThreads interaction (data from one thread to another) c#
    primarykey
    data
    text
    <p>I need to pass information from thread of scanning data to recording information thread(write to xml file). It should looks something like this:</p> <p>Application.Run() - complete</p> <p>Scanning thread - complete</p> <p>Writing to xlm thread - ???</p> <p>UI update thread - I think I did it</p> <p>And what i got now:</p> <pre><code> private void StartButtonClick(object sender, EventArgs e) { if (FolderPathTextBox.Text == String.Empty || !Directory.Exists(FolderPathTextBox.Text)) return; { var nodeDrive = new TreeNode(FolderPathTextBox.Text); FolderCatalogTreeView.Nodes.Add(nodeDrive); nodeDrive.Expand(); var t1 = new Thread(() =&gt; AddDirectories(nodeDrive)); t1.Start(); } } private void AddDirectories(TreeNode node) { string strPath = node.FullPath; var dirInfo = new DirectoryInfo(strPath); DirectoryInfo[] arrayDirInfo; FileInfo[] arrayFileInfo; try { arrayDirInfo = dirInfo.GetDirectories(); arrayFileInfo = dirInfo.GetFiles(); } catch { return; } //Write data to xml file foreach (FileInfo fileInfo in arrayFileInfo) { WriteXmlFolders(null, fileInfo); } foreach (DirectoryInfo directoryInfo in arrayDirInfo) { WriteXmlFolders(directoryInfo, null); } foreach (TreeNode nodeFil in arrayFileInfo.Select(file =&gt; new TreeNode(file.Name))) { FolderCatalogTreeView.Invoke(new ThreadStart(delegate { node.Nodes.Add(nodeFil); })); } foreach (TreeNode nodeDir in arrayDirInfo.Select(dir =&gt; new TreeNode(dir.Name))) { FolderCatalogTreeView.Invoke(new ThreadStart(delegate {node.Nodes.Add(nodeDir); })); StatusLabel.BeginInvoke(new MethodInvoker(delegate { //UI update...some code here })); AddDirectories(nodeDir); } } private void WriteXmlFolders(DirectoryInfo dir, FileInfo file) {//writing information into the file...some code here} </code></pre> <p>How to pass data from AddDirectories(recursive method) thread to WriteXmlFolders thread?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload