运行回程服务断点没有命中dispatcherTimer_Tick [英] To runbackground service Breakpoint not hitting dispatcherTimer_Tick

查看:82
本文介绍了运行回程服务断点没有命中dispatcherTimer_Tick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




dispatcherTimer.Tick += dispatcherTimer_Tick;
   dispatcherTimer.Interval = new TimeSpan(0, 0, 10); // TimeSpan for 10 secs



I我有


I am having

async void dispatcherTimer_Tick(object sender, object e)



这个方法断点应该在10秒后命中但是没有发生任何人都可以告诉我怎么能跑?




this method Breakpoint should hit after 10 seconds but it's not happening Can any one tell me how can I able to run?

public class BackGroundService
 {
      DispatcherTimer dispatcherTimer;

 public void DispatcherTimerSetup(HttpClient httpClient, string lati, string longi, string UserId)
 {
   dispatcherTimer = new DispatcherTimer();
   dispatcherTimer.Tick += dispatcherTimer_Tick;
   dispatcherTimer.Interval = new TimeSpan(0, 0, 10); // TimeSpan for 10 secs
   if (!dispatcherTimer.IsEnabled)
   {
      dispatcherTimer.Start();
   }
 }
 async void dispatcherTimer_Tick(object sender, object e)
 {
  ILinkUser Objuser = new LinkUsers();
  await Objuser.LinkUsertoGroups(UserCookieWrapper.UserAccessToken, Latitude, Longitude, UserId);
  await Objuser.LinkDeptUsertoSGroups(UserCookieWrapper.UserAccessToken, Latitude, Longitude, UserId);
 }
}

推荐答案

检查计时器是否启用


问题在这里



problem is here

if (!dispatcherTimer.IsEnabled)
            {
               dispatcherTimer.Start();
            }





而不是这个





instead wite this

if (dispatcherTimer.IsEnabled)
            {
               dispatcherTimer.Start();
            }


这篇关于运行回程服务断点没有命中dispatcherTimer_Tick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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