Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:

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

I am having
C#
async void dispatcherTimer_Tick(object sender, object e)

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

C#
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);
 }
}
Posted

check if timer is enabled true or not
 
Share this answer
 
Comments
Balu Balaji 6-Dec-13 5:25am    
Break Point hitting here means it's enabled only know I think so......

if (!dispatcherTimer.IsEnabled)
{
dispatcherTimer.Start();
}
Balu Balaji 6-Dec-13 6:01am    
I checked my program in windows forms it's working fine the problem is i am calling from controller that's why it's not working I think so any IDea?


[MustBeLoggedIn, Filters.Compress]
public void GetLocation(string lati, string longi)
{
string UserId="";
clsBOUser objBOuser = new clsBOUser();
using (clsBLLUsers objBLLUser = new clsBLLUsers())
{ BackGroundService objBGServices = new BackGroundService();
objBGServices.DispatcherTimerSetup(httpClient, lati, longi, UserId);
}
agent_kruger 6-Dec-13 6:15am    
oh sorry didn't see it
problem is here

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


instead wite this

if (dispatcherTimer.IsEnabled)
            {
               dispatcherTimer.Start();
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900