mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
使主界面常用UI操作方法线程安全
This commit is contained in:
@@ -114,6 +114,12 @@ namespace Netch.Forms
|
||||
|
||||
public void OnBandwidthUpdated(long download)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action<long>(OnBandwidthUpdated), download);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
UsedBandwidthLabel.Text = $"{i18N.Translate("Used", ": ")}{Bandwidth.Compute(download)}";
|
||||
@@ -124,13 +130,20 @@ namespace Netch.Forms
|
||||
LastDownloadBandwidth = download;
|
||||
Refresh();
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBandwidthUpdated(long upload, long download)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action<long, long>(OnBandwidthUpdated), upload, download);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (upload < 1 || download < 1)
|
||||
@@ -147,8 +160,9 @@ namespace Netch.Forms
|
||||
LastDownloadBandwidth = download;
|
||||
Refresh();
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace Netch.Forms
|
||||
get => _state;
|
||||
private set
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action(() => { State = value; }));
|
||||
return;
|
||||
}
|
||||
|
||||
void StartDisableItems(bool enabled)
|
||||
{
|
||||
ServerComboBox.Enabled =
|
||||
@@ -61,7 +67,7 @@ namespace Netch.Forms
|
||||
ControlButton.Text = i18N.Translate("Stop");
|
||||
|
||||
StatusTextAppend(_mainController.PortInfo);
|
||||
|
||||
|
||||
ProfileGroupBox.Enabled = true;
|
||||
|
||||
UsedBandwidthLabel.Visible /*= UploadSpeedLabel.Visible*/ = DownloadSpeedLabel.Visible = true;
|
||||
@@ -94,6 +100,12 @@ namespace Netch.Forms
|
||||
|
||||
public void NatTypeStatusText(string text = "", string country = "")
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action<string, string>(NatTypeStatusText), text, country);
|
||||
return;
|
||||
}
|
||||
|
||||
if (State != State.Started)
|
||||
{
|
||||
NatTypeStatusLabel.Text = "";
|
||||
@@ -162,6 +174,12 @@ namespace Netch.Forms
|
||||
/// <param name="text"></param>
|
||||
public void StatusText(string text)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action<string>(StatusText), text);
|
||||
return;
|
||||
}
|
||||
|
||||
StatusLabel.Text = i18N.Translate("Status", ": ") + text;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user