Skip to content

Commit

Permalink
MavFTPUI: fix crossthread call
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Jun 19, 2021
1 parent 428d4fd commit 6301668
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Controls/MavFTPUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,15 @@ private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
cancel.Cancel();
_mavftp.kCmdResetSessions();
};
prd.doWorkArgs.ForceExit = false;
prd.doWorkArgs.ForceExit = false;
string fullName = ((DirectoryInfo)listView1SelectedItem.Tag).FullName;
string text = listView1SelectedItem.Text;
prd.DoWork += (iprd) =>
{
var success = _mavftp.kCmdRemoveFile(((DirectoryInfo) listView1SelectedItem.Tag).FullName + "/" +
listView1SelectedItem.Text, cancel);
{
var success = _mavftp.kCmdRemoveFile(fullName + "/" +
text, cancel);
if (!success)
CustomMessageBox.Show("Failed to delete file", listView1SelectedItem.Text);
CustomMessageBox.Show("Failed to delete file", text);
};

prd.RunBackgroundOperationAsync();
Expand Down Expand Up @@ -474,10 +476,11 @@ private void ListView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
prd.doWorkArgs.ForceExit = false;
var selectedNodeFullPath = treeView1.SelectedNode.FullPath;
var text = listView1.SelectedItems[0].Text;
string label = e.Label;
prd.DoWork += (iprd) =>
{
{
_mavftp.kCmdRename(selectedNodeFullPath + "/" + text,
selectedNodeFullPath + "/" + e.Label, cancel);
selectedNodeFullPath + "/" + label, cancel);
};

prd.RunBackgroundOperationAsync();
Expand All @@ -501,9 +504,10 @@ private void NewFolderToolStripMenuItem_Click(object sender, EventArgs e)
_mavftp.kCmdResetSessions();
};
prd.doWorkArgs.ForceExit = false;
string fullPath = treeView1.SelectedNode.FullPath;
prd.DoWork += (iprd) =>
{
if (!_mavftp.kCmdCreateDirectory(treeView1.SelectedNode.FullPath + "/" + folder,
if (!_mavftp.kCmdCreateDirectory(fullPath + "/" + folder,
cancel))
{
CustomMessageBox.Show("Failed to create directory", Strings.ERROR);
Expand All @@ -530,9 +534,12 @@ private void GetCRC32ToolStripMenuItem_Click(object sender, EventArgs e)
};
prd.doWorkArgs.ForceExit = false;
var crc = 0u;
string fullPath = treeView1.SelectedNode.FullPath;
string text = listView1.SelectedItems[0].Text;
prd.DoWork += (iprd) =>
{
_mavftp.kCmdCalcFileCRC32(treeView1.SelectedNode.FullPath + "/" + listView1.SelectedItems[0].Text,

_mavftp.kCmdCalcFileCRC32(fullPath + "/" + text,
ref crc, cancel);
};

Expand Down

0 comments on commit 6301668

Please sign in to comment.