CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Issue With Dispatch Timer

    I have a WPF application. I have a panel that I want to repopulate every 1 minute getting data from the network. I know that I can use the DispatcherTimer class to set the timespan for ticks and make my code execute in every 1 minute.
    The problem here is the my GUI freezes and becomes unresponsive as my code is busy fetching data from the network. I would like to know that is there any way in WPF to get rid of it as this is a new World for me.

    I am doing it like this:

    DispatcherTimer timer = new DispatcherTimer();



    Windiw_Loaded()

    {

    timer.Interval = TimeSpan.FromMilliseconds(1000);



    timer.Tick += new EventHandler(timer_Tick);

    timer.Start();

    }



    private void timer_Tick(object sender, EventArgs e)

    {

    FetchNewAttendence();

    }

    This code freezes my GUI. Please help.

    Thanks,
    Namrata

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Issue With Dispatch Timer

    Start a new thread (or use the BackgroundWorker class) and put the retrieval code there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured