0
私はC#で新しく、エラーが発生しています。System.InvalidOperationException PHPで作成したAPIを呼び出すコードがあります。私の目標は、APIがロードされる前に読み込みアニメーションを作成し、後で非表示にすることです。c#restsharp System.InvalidOperationException
loading.Visible = true;
login.Enabled = false;
var Client = new RestClient("http://localhost/online-lms/login.php");
var request = new RestRequest(Method.POST);
Client.ExecuteAsync<Form1>(request, (response) => {
loading.Width = 200;
login.Enabled = true;
if (response.StatusCode == System.Net.HttpStatusCode.OK) {
JObject o = JObject.Parse(response.Content);
}
});
エラー:
System.InvalidOperationException: 'Cross-thread operation not valid: Control 'loading' accessed from a thread other than the thread it was created on.'
PS:私は、Windowsフォームアプリケーションを作成しています。
これに関する助力?
WPFアプリケーションまたはWindowsフォームアプリケーションを作成しようとしていますか? –
私はWindowsフォームアプリケーションを作成しています@ThiyaguRajendran –
別のスレッドからアクセスしようとするとシンプルなUIelementが呼び出されます。今すぐ例を投稿します –