Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (this.InvokeRequired)
- {
- BeginInvoke(new MyDelegate(delegate()
- {
- timer.Enabled = true;
- }));
- }
- public bool TimerEnable
- {
- set
- {
- this.Invoke((MethodInvoker)delegate
- {
- this.timer.Enabled = value;
- });
- }
- }
- public static void timerEnable()
- {
- var form = Form.ActiveForm as Form1;
- if (form != null)
- form.TimerEnable = true;
- }
- public static class ControlExtensions
- {
- public static TResult InvokeEx<TControl, TResult>(this TControl control,
- Func<TControl, TResult> func)
- where TControl : Control
- {
- if (control.InvokeRequired)
- {
- return (TResult)control.Invoke(func, control);
- }
- else
- {
- return func(control);
- }
- }
- }
- new Thread(() =>
- {
- Thread.Sleep(1000);
- this.InvokeEx(f => f.timer1.Enabled = true);
- }).Start();
Add Comment
Please, Sign In to add comment