mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
InputText: Code cleanup
This commit is contained in:
parent
4cf416bd3f
commit
7f8e739ae6
@ -329,7 +329,7 @@ namespace InputText
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
this.drBackup = DialogResult.Cancel;
|
||||
this.drBackup = DialogResult.Abort;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,24 @@ namespace InputText
|
||||
if (go)
|
||||
{
|
||||
ExecuteBangParam param = new ExecuteBangParam(args);
|
||||
if (ReadOptions(param)) // Read all options in advance for thread-safety
|
||||
if (ReadOptions(param)) // Read all options in main thread for thread-safety
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(ExecuteBangThread, param);
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ExecuteCommands(param);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
API.Log(API.LogType.Error, "C# plugin in ExecuteBang(), " + ex.GetType().ToString() + ": " + ex.Message);
|
||||
}
|
||||
|
||||
lock (this.locker)
|
||||
{
|
||||
this.IsExecuteBangRunning = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -87,7 +102,7 @@ namespace InputText
|
||||
}
|
||||
}
|
||||
|
||||
internal class ExecuteBangParam
|
||||
private class ExecuteBangParam
|
||||
{
|
||||
internal enum BangType
|
||||
{
|
||||
@ -109,28 +124,12 @@ namespace InputText
|
||||
}
|
||||
};
|
||||
|
||||
private void ExecuteBangThread(object state)
|
||||
{
|
||||
ExecuteBangParam param = (ExecuteBangParam)state;
|
||||
|
||||
try
|
||||
{
|
||||
ExecuteCommands(param);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
API.Log(API.LogType.Error, "C# plugin in ExecuteBang(), " + ex.GetType().ToString() + ": " + ex.Message);
|
||||
}
|
||||
|
||||
lock (this.locker)
|
||||
{
|
||||
this.IsExecuteBangRunning = false;
|
||||
}
|
||||
}
|
||||
private bool _IsFinalizing = false;
|
||||
|
||||
internal void Dispose()
|
||||
{
|
||||
CloseInputBox();
|
||||
this._IsFinalizing = true;
|
||||
FinalizePluginCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,6 +264,9 @@ namespace InputText
|
||||
|
||||
lock (this._InputBoxLocker)
|
||||
{
|
||||
if (this._IsFinalizing)
|
||||
return null;
|
||||
|
||||
SkinWindow skin = new SkinWindow(rm);
|
||||
|
||||
// Create the form. 'InputBox' is a .NET form with a textbox and two button controls on it.
|
||||
@ -352,7 +355,7 @@ namespace InputText
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CloseInputBox()
|
||||
private void FinalizePluginCode()
|
||||
{
|
||||
lock (this._InputBoxLocker)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user