当前位置: 首页>>代码示例>>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;未经允许,请勿转载。