當前位置: 首頁>>代碼示例>>C#>>正文


C# TextBox.Invoke方法代碼示例

本文整理匯總了C#中System.Windows.Forms.TextBox.Invoke方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.Invoke方法的具體用法?C# TextBox.Invoke怎麽用?C# TextBox.Invoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.TextBox的用法示例。


在下文中一共展示了TextBox.Invoke方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: StartAnomalyDetection

 public static void StartAnomalyDetection(TextBox warningTextBox)
 {     
     if (DoneSettingNormalUsage)
     {
         if (CPUMonitor.CPUCounter > NormalCPU)
         {
             if (warningTextBox.Text.Length == 0)
             {
                 warningTextBox.Invoke(new Action(() =>
                 {
                     warningTextBox.Text = "CPU Usage: " + CPUMonitor.CPUCounter.ToString("F2") + "%";
                     CPUMonitor.CPUWarnings = warningTextBox.Text;
                 }));
             }
             else
             {
                 warningTextBox.Invoke(new Action(() =>
                 {
                 warningTextBox.AppendText("\r\nCPU Usage: " + CPUMonitor.CPUCounter.ToString("F2") + "%");
                     CPUMonitor.CPUWarnings = warningTextBox.Text;
                 }));
             }
         }
     }
 }
開發者ID:MikeHardman,項目名稱:acIDS,代碼行數:25,代碼來源:CPUAnomalies.cs

示例2: CreateMessage

        public static void CreateMessage(TextBox box, string msg, bool timer = true, bool appendText = true)
        {
            //set timer string depending on parameter
            string timerLinespacing = "  ";
            string theTime;
            string newline = "\r\n";
            if (timer) { theTime = DateTime.Now.ToString("HH:mm:ss tt"); }
            else { theTime = ""; }

            if (appendText)
            {
                if (box.InvokeRequired)
                {
                    box.Invoke(new MethodInvoker(delegate { box.Text += theTime + timerLinespacing + msg + newline; }));
                }
                else
                {
                    box.Text += theTime + timerLinespacing + msg + newline;
                }
            }
            else
            {
                if (box.InvokeRequired)
                {
                    box.Invoke(new MethodInvoker(delegate { box.Text = msg + newline; }));
                }
                else
                {
                    box.Text = msg + newline;
                }
            }
        }
開發者ID:Ckrag,項目名稱:boligportalbot,代碼行數:32,代碼來源:CrossThreadMsg.cs

示例3: updateRegisterState

 private void updateRegisterState(TextBox txt, Register register)
 {
     txt.Invoke((MethodInvoker)(() =>
     {
         txt.Text = _vm.cpu.Registers[register].ToString();
     }));
 }
開發者ID:claassen,項目名稱:RIVM,代碼行數:7,代碼來源:Debugger.cs

示例4: SetTextBoxSafe

 /// <summary>
 /// Sets textbox text
 /// </summary>
 /// <param name="tb"></param>
 /// <param name="text"></param>
 private static void SetTextBoxSafe(TextBox tb, string text)
 {
     if (tb.InvokeRequired)
         tb.Invoke(new Action(() => tb.Text = text));
     else
         tb.Text = text;
 }
開發者ID:bassebaba,項目名稱:ModsisHaxx,代碼行數:12,代碼來源:Form1.cs

示例5: ProcessMonitoring

        public static async void ProcessMonitoring(TextBox usageTextBox, TextBox listTextBox)
        {
            int changed = ProcessCounter;
            string[] data;
            while (true)
            {
                await Task.Delay(1000);
                CurrentNumberProcesses();
                usageTextBox.Invoke(new Action(() =>
                {
                    usageTextBox.Text = ProcessCounter + "";
                }));

                if (changed != ProcessCounter)
                {
                    changed = ProcessCounter;
                    listTextBox.Invoke(new Action(() =>
                    {
                        data = ReadProcesses();

                        foreach (string pData in data)
                        {
                            if (listTextBox.Text.Length < 0)
                                listTextBox.Text = pData;
                            else
                                listTextBox.AppendText($"\r\n{pData}");
                        }
                    }));
                }
            }
        }
開發者ID:MikeHardman,項目名稱:acIDS,代碼行數:31,代碼來源:ProcessMonitor.cs

示例6: CPUMonitoring

        //Function will read and display current CPU usage
        public static async void CPUMonitoring(TextBox usageTextBox, TextBox warningTextBox)
        {

            PerformanceCounter cpuCounter = new PerformanceCounter();
            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName = "% Processor Time";
            cpuCounter.InstanceName = "_Total";

            while (true)
            {
                //First value always returns a 0
                var unused = cpuCounter.NextValue();
                await Task.Delay(1000);

                usageTextBox.Invoke(new Action(() =>
                {
                    CPUCounter = cpuCounter.NextValue();
                    usageTextBox.Text = CPUCounter.ToString("F2") + "%";
                }));
                CPUCalculations();
                CPUAnomalies.StartAnomalyDetection(warningTextBox);

                if (mainMenu.done)
                    break;
            }
        }
開發者ID:MikeHardman,項目名稱:acIDS,代碼行數:27,代碼來源:CPUMonitor.cs

示例7: Main

        static void Main()
        {

            var form = new Form { Width = 800, Height = 600};
            textBox = new TextBox() { Dock = DockStyle.Fill, Multiline = true, Text = "Interact with the mouse or the keyboard...\r\n", ReadOnly = true};
            form.Controls.Add(textBox);
            form.Visible = true;

            // setup the device
            Device.RegisterDevice(UsagePage.Generic, UsageId.GenericMouse, DeviceFlags.None);
            Device.MouseInput += (sender, args) => textBox.Invoke(new UpdateTextCallback(UpdateMouseText), args);

            Device.RegisterDevice(UsagePage.Generic, UsageId.GenericKeyboard, DeviceFlags.None);
            Device.KeyboardInput += (sender, args) => textBox.Invoke(new UpdateTextCallback(UpdateKeyboardText), args);

            Application.Run(form);
        }
開發者ID:Nezz,項目名稱:SharpDX,代碼行數:17,代碼來源:Program.cs

示例8: add_text

 public static void add_text(TextBox tb, object s)
 {
     if (tb.InvokeRequired)
         tb.Invoke(new Action<TextBox, object>(add_text), new object[] { tb, s });
     else
     {
         tb.AppendText(s.ToString());
         tb.ScrollToCaret();
     }
 }
開發者ID:HowieXue,項目名稱:Hospital_projs,代碼行數:10,代碼來源:Helper.cs

示例9: GetTextBoxText

 private string GetTextBoxText(TextBox textbox)
 {
     string returnValue = null;
     if (textbox.InvokeRequired)
         textbox.Invoke((MethodInvoker)
                        delegate { returnValue = GetTextBoxText(textbox); });
     else
         return textbox.Text;
     return returnValue;
 }
開發者ID:krishnasqor,項目名稱:ErlangCodes,代碼行數:10,代碼來源:Form1.cs

示例10: showdata

 public void showdata(string mac, string ip, float nhietdo, float doam, float nguon, TextBox text)
 {
     text.Invoke(new EventHandler(delegate
     {
         if (index == 2)
         {
             text.Text = "Sensor " + ip + "(" + mac + ")\r\nNhiet do : " + nhietdo + "\r\nDo am : " + doam + "\r\nNang luong : " + nguon;
             mypanel.Show();
         }
     }));
 }
開發者ID:ThuTrangK57,項目名稱:sigateWsan,代碼行數:11,代碼來源:ShowData.cs

示例11: UpdateUI

 private void UpdateUI(TextBox tb, int data)
 {
     if (textBox1.InvokeRequired)
     {
         tb.Invoke(new UpdateStatus(UpdateUI), new object[] {tb, data });
     }
     else
     {
         tb.Text += data + Resources.TextSeparator;
     }
 }
開發者ID:neerajsoni,項目名稱:Patterns,代碼行數:11,代碼來源:Form1.cs

示例12: updateTextBox

 public static void updateTextBox(string strText, TextBox tbToUse)
 {
     if (tbToUse.InvokeRequired)
     {
         updateTextBoxCallback utbCallback = new updateTextBoxCallback(updateTextBox);
         tbToUse.Invoke(utbCallback, new object[] { strText, tbToUse });
     }
     else
     {
         tbToUse.Text = strText + Environment.NewLine + tbToUse.Text;
     }
 }
開發者ID:asr340,項目名稱:owasp-code-central,代碼行數:12,代碼來源:GUI.cs

示例13: SetTextBoxValue

 private void SetTextBoxValue(string value, TextBox ctr)
 {
     Action<string> setValueAction = text => ctr.AppendText(value);//Action<T>本身就是delegate類型,省掉了delegate的定義
     if (ctr.InvokeRequired)
     {
         ctr.Invoke(setValueAction, value);
     }
     else
     {
         setValueAction(value);
     }
 }
開發者ID:caocf,項目名稱:workspace-kepler,代碼行數:12,代碼來源:UCServiceRunLog.cs

示例14: GetTextBoxText

 public static string GetTextBoxText(TextBox box)
 {
     if (box.InvokeRequired)
     {
         Func<TextBox, string> deleg = new Func<TextBox, string>(GetTextBoxText);
         return box.Invoke(deleg, new object[] { box }).ToString();
     }
     else
     {
         return box.Text;
     }
 }
開發者ID:NikitaPirat,項目名稱:controlPrg,代碼行數:12,代碼來源:Sample_Form.cs

示例15: PrintText

 public void PrintText(TextBox textbox, string text)
 {
     if (textbox.InvokeRequired)
     {
         textbox.Invoke(new PrintTextCallback(PrintText), textbox, text);
     }
     else
     {
         textbox.Text += text;
         textbox.SelectionStart = textbox.Text.Length;
         textbox.ScrollToCaret();
     }
 }
開發者ID:colombmo,項目名稱:itsi-gamification,代碼行數:13,代碼來源:TestPMForm1.cs


注:本文中的System.Windows.Forms.TextBox.Invoke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。