ciao!
vorrei eseguire una richiesta asincrona, ma ho un problema con Dispatcher.BeginInvoke.
questo il metodo:
questo l'errore che mi da:codice:private void GetResponseCallback(IAsyncResult ar) { try { HttpWebRequest request = (HttpWebRequest)ar.AsyncState; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) { String json = streamReader.ReadToEnd(); var s = new JavaScriptSerializer(); var cl = s.Deserialize<List<Cliente>>(json); Dispatcher.BeginInvoke(new Action(() => { dg.ItemsSource = cl; })); AllDone.Set(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
ma leggendo vari esempi sul web, usando tutti questa sintassi.codice:An object reference is required for the non-static field, method, or property 'System.Windows.Threading.Dispatcher.BeginInvoke(System.Delegate, params object[])'
quindi non riesco a capire dove stia sbagliando!
qualche idea?

Rispondi quotando