DispatcherTimer.Start()'必须声明一个主体,因为它在MVC4中没有标记为abstract,extern或partial [英] DispatcherTimer.Start()' must declare a body because it is not marked abstract, extern, or partial in MVC4

查看:205
本文介绍了DispatcherTimer.Start()'必须声明一个主体,因为它在MVC4中没有标记为abstract,extern或partial的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void DispatcherTimerSetup(HttpClient httpClient)
       {
           Client = httpClient;
           dispatcherTimer = new DispatcherTimer();
           dispatcherTimer.Tick += dispatcherTimer_Tick;
           dispatcherTimer.Interval = new TimeSpan(0, 1, 0); // TimeSpan for 1 Minute 0 secs
           if (!dispatcherTimer.IsEnabled)
           {
               dispatcherTimer.Start();
           }
       }










class DispatcherTimer
   {
       public void Start();
   }







这里我收到此错误



DispatcherTimer.Start()'必须声明一个正文,因为它没有标记为abstract,extern或partial




here I am getting this ERROR

DispatcherTimer.Start()' must declare a body because it is not marked abstract, extern, or partial

推荐答案

在你的 DispatcherTimer 类,你声明一个 Start()方法,但你没有给它一个正文(即:你没有实现方法)。您应该:

In your DispatcherTimer class, you declare a Start() method but you do not give it a body (i.e.: you do not implement the method). You should have:
class DispatcherTimer
{
   public void Start()
   {
      // Your implementation of the Start() method
   }
}



或者将类创建为抽象,将方法创建为虚拟:


or create the class as abstract and the method as virtual:

abstract class DispatcherTimer
{
   public virtual void Start();
}


首先我们需要使用System.Windows.Threading添加此NameSpace

;



之后我们需要添加Windowsbase.dll程序集

现在我的解决方案工作正常



感谢所有
First we need to add this NameSpace
using System.Windows.Threading;

After that we need to add Windowsbase.dll Assembly
Now My solution working fine

Thanks to all


这篇关于DispatcherTimer.Start()'必须声明一个主体,因为它在MVC4中没有标记为abstract,extern或partial的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆