Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use C # thread to make pop-up window effect

Shulou Source: shulou.com Published: 2022-06-01 18:16:03 10月06日 Update

Most people do not understand the knowledge points of this article "how to use C# thread to make pop-up window effect", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article, let's take a look at this article "how to use C# thread to make pop-up window effect" article.

First create a ShowFrom form in which two buttons are placed to confirm and cancel, respectively.

Add the following events to the button

Private void btn_ok_Click (object sender, EventArgs e) {this.DialogResult = DialogResult.OK; this.Close ();} private void btn_cancle_Click (object sender, EventArgs e) {this.DialogResult = DialogResult.Cancel; this.Close ();}

You can call the pop-up window by establishing the following function in the main form

Public static bool MsgShow (string msg = "undefined action prompt", bool bcancel = false) {/ / device pauses, beep starts / / VAR.gsys_set.beep_en = true Task mtask = new Task (() = > {lock (WarnObj) {warning frWarning = new warning (); / / error form frWarning.TopMost = true; frWarning.BackColor = Color.Yellow FrWarning.lb_msg.Text = msg; if (bcancel) {frWarning.btn_cancle.Visible = true; frWarning.btn_cancle.Enabled = true } frWarning.ShowDialog (); VAR.msg.AddMsg (Msg.EM_MSGTYPE.SAVE_WAR, string.Format ("{0}", msg)) If (frWarning.DialogResult = = DialogResult.OK) {frWarning.Dispose (); return true;} else {frWarning.Dispose () Return false;}); mtask.Start (); mtask.Wait (); return mtask.Result } private void button1_Click_1 (object sender, EventArgs e) {var ret = actiom.MsgShow ("ceshi", true); if (ret) MessageBox.Show ("ok"); else MessageBox.Show ("err");}

Results:

The above is about the content of this article on "how to make pop-up window effect with C # thread". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Tags: Content forms effects threads clips production buttons articles knowledge articles two in events values functions most that is more steps knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL Xiaomi macOS Linux