Thread pool
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -47,7 +47,7 @@ namespace OpenSaveCloudClient
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
LockControls(true);
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -78,7 +78,7 @@ namespace OpenSaveCloudClient
|
||||
LockControls(false);
|
||||
});
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void LockControls(bool value)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenSaveCloudClient.Core
|
||||
{
|
||||
saves = new List<GameSave>();
|
||||
Load();
|
||||
new Thread(() => CleanArchiveFolder()).Start();
|
||||
ThreadPool.QueueUserWorkItem(delegate { CleanArchiveFolder(); });
|
||||
}
|
||||
|
||||
public static SaveManager GetInstance()
|
||||
|
||||
@@ -34,12 +34,12 @@ namespace OpenSaveCloudClient
|
||||
|
||||
private void DownloadGameForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
new Thread(() => {
|
||||
ThreadPool.QueueUserWorkItem(delegate {
|
||||
List<Game>? remoteGames = serverConnector.GetGamesInfo();
|
||||
this.Invoke((MethodInvoker)delegate {
|
||||
UpdateRemoteList(remoteGames);
|
||||
});
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateRemoteList(List<Game>? remoteGames)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenSaveCloudClient
|
||||
taskManager.TaskChanged += taskManager_TaskChanged;
|
||||
logManager.Cleared += LogManager_LogCleared;
|
||||
logManager.NewMessage += LogManager_NewMessage;
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
this.Invoke((MethodInvoker)delegate {
|
||||
CheckPaths();
|
||||
@@ -75,7 +75,7 @@ namespace OpenSaveCloudClient
|
||||
SetTaskFailed(taskUuid);
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void CheckPaths()
|
||||
@@ -124,7 +124,7 @@ namespace OpenSaveCloudClient
|
||||
Close();
|
||||
} else
|
||||
{
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
string taskUuid = StartTask("Detecting changes...", true, 1);
|
||||
try
|
||||
@@ -137,7 +137,7 @@ namespace OpenSaveCloudClient
|
||||
logManager.AddError(e);
|
||||
SetTaskFailed(taskUuid);
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
SetAdminControls();
|
||||
Enabled = true;
|
||||
AboutButton.Enabled = true;
|
||||
@@ -171,7 +171,7 @@ namespace OpenSaveCloudClient
|
||||
AddGameForm form = new(_client);
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
GameSave newGame = form.Result;
|
||||
new Thread(() => AddGameToLibrary(newGame)).Start();
|
||||
ThreadPool.QueueUserWorkItem(delegate { AddGameToLibrary(newGame); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,12 +335,12 @@ namespace OpenSaveCloudClient
|
||||
private void SyncButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LockCriticalControls(true);
|
||||
new Thread(() => {
|
||||
ThreadPool.QueueUserWorkItem(delegate {
|
||||
serverConnector.Synchronize();
|
||||
this.Invoke((MethodInvoker)delegate {
|
||||
LockCriticalControls(false);
|
||||
});
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void DownloadButton_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenSaveCloudClient
|
||||
LockControls(false);
|
||||
return;
|
||||
}
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace OpenSaveCloudClient
|
||||
LockControls(false);
|
||||
});
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void LockControls(bool value)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenSaveCloudClient
|
||||
LockControls(false);
|
||||
return;
|
||||
}
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
serverConnector.ChangePassword(new NewPassword { Password = NewPasswordBox.Text, VerifyPassword = PasswordAgainBox.Text });
|
||||
this.Invoke((MethodInvoker)delegate {
|
||||
@@ -66,7 +66,7 @@ namespace OpenSaveCloudClient
|
||||
PasswordAgainBox.Clear();
|
||||
LockControls(false);
|
||||
});
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void LockControls(bool l)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenSaveCloudClient
|
||||
|
||||
private void LoadUsers()
|
||||
{
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
List<User>? users = serverConnector.GetUsers();
|
||||
if (users != null)
|
||||
@@ -45,7 +45,7 @@ namespace OpenSaveCloudClient
|
||||
UpdateRemoteList(users);
|
||||
});
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateRemoteList(List<User> users)
|
||||
@@ -107,7 +107,7 @@ namespace OpenSaveCloudClient
|
||||
long userId = Convert.ToInt64(item.SubItems[1].Text);
|
||||
ids.Add(userId);
|
||||
}
|
||||
new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -134,7 +134,7 @@ namespace OpenSaveCloudClient
|
||||
LockControls(false);
|
||||
});
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user