Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使网站页面/url地址在计时器滴答声事件中每X秒自动刷新一次?_C#_Winforms - Fatal编程技术网

C# 如何使网站页面/url地址在计时器滴答声事件中每X秒自动刷新一次?

C# 如何使网站页面/url地址在计时器滴答声事件中每X秒自动刷新一次?,c#,winforms,C#,Winforms,我在计时器滴答声事件中有这一行: HttpContext.Current.Response.Redirect("https://www.facebook.com/groups/mygroup/"); 但我得到的异常电流为空 Object reference not set to an instance of an object System.NullReferenceException was unhandled HResult=-2147467261 Message=Object

我在计时器滴答声事件中有这一行:

HttpContext.Current.Response.Redirect("https://www.facebook.com/groups/mygroup/");
但我得到的异常电流为空

Object reference not set to an instance of an object

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=ScrollLabel
  StackTrace:
       at ScrollLabelTest.Form1.timer1_Tick(Object sender, EventArgs e) in e:\scrolllabel\ScrollLabel\ScrollLabel\Form1.cs:line 272
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at ScrollLabelTest.Program.Main() in e:\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
表格1第272行为:

HttpContext.Current.Response.Redirect("https://www.facebook.com/groups/mygroup/");

如果您在Windows窗体中使用它,则不存在HttpContext,因此对HttpContext.Current的引用将引发空引用异常