how do i let UIthread to execute a command when im in some thread
the code below is called by a thread but the line i want to run in UIthread .. doesn't work if i called it like that ..
the form lag a little and the process fan got fast like it's in infinity loop.. then it gives me an error "stackoverflowexception"
my application is a file manager .. (copy, cut, paste, new folder..etc) .. and dirRecursive(string path) .. shows me the files and folders in a listView with its icons so every time i do something like (new folder or paste) i have to call dirRecursive to update the listView
note:
please help :) thanks in advance
private void PasteFromCopy(object dest)
{
foreach (ListViewItem item in copiedItems)
{
string _dest = (string)dest;
string itemName = item.Text;
string itemPath = item.ToolTipText;
string itemDest = Path.Combine(_dest, itemName);
if (IsFolder(itemPath))
{
if (Directory.Exists(itemDest))
{
if (MessageBox.Show(itemName + " is already exists .. Do you want to overwrite it and its all contents?"
, "Overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
{
CopyDirectory(itemPath, itemDest, true);
}
}
else
CopyDirectory(itemPath, itemDest, false);
}
else
{
if (File.Exists(itemDest))
{
if (MessageBox.Show(itemName + " is already exists .. Do you want to overwrite it?"
, "Overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
{
InfoLabel("Copying " + itemName + " ...");
File.Copy(itemPath, itemDest, true);
}
}
else
{
InfoLabel("Copying " + itemName + " ...");
File.Copy(itemPath, itemDest, false);
}
}
InfoLabel("Paste done.");
dirRecursive(currAddress); // here is line i need to execute from UIthread
}
}