title: Threading in WPF
body: <p>Currently I am working in WPF application where i am dealing a scenario.</p>
  
  <p>My application has search functionality and depending on the search criteria grid will be populated. To make application responsive we have implemented TPL.</p>
  
  <p>Something like this</p>
  
  <pre><code>Task.Factory.StartNew(() =&gt;
   {
    //Webservice Call
     Dispatcher.Invoke(() =&gt;
     {
       //Data from webservice assigned to Collection binded to Grid
     });
     }
  );
  </code></pre>
  
  <p>I have one problem.</p>
  
  <p>Let's say I have entered search criteria 'A' and hit search, within a second i changed my mind and updated the search criteria with 'B', i hit the search button , again i thought this wrong i have to search something else, i changed the criteria as 'C' and again click the Search. 
  The problem is service response for A in 20 seconds,for B 25 seconds but for C its only 5 seconds.</p>
  
  <p>As per my search i have to show latest search criteria and that would be C but my data is getting updated with B's record. i looked into web but did not able to get any help. Am i missing something. Any help will be appreciated. </p>