Sujeet Raman

Sujeet Raman

  • 799
  • 915
  • 334.2k

WHAT IS this.Dispatcher.BeginInvoke(() => AND ITS USE???

Sep 25 2015 2:15 AM
HAI IAM GETTING ERROR in my code i cant fix can you help me? am trying to develope a widows phone 8.1 chat app and am new to this
 
 
ERROR IS IN  this.Dispatcher.BeginInvoke(() =>  SECTION..
widows.ui.core.core dispatcher does not contain adefinition for BeginInvoke and no extension methode BeginInvoke accepting a first argument of  type windows.ui.core.core dispatcher could not find(are you missing a using directives or assembly refference?)
 
 
 
 
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Net.XMPP;
using System.Threading;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
namespace test_demo
{
public sealed partial class MainPage : Page
{
public XMPPClient ObjXmppClient { get; set; }
public XMPPConnection ObjXmppCon { get; set; }
public string username;
public string password;
public readonly string server = "taurus";
private Boolean IsXmppSuccess { get; set; }
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
void ObjXmppCon_OnAsyncConnectFinished(xmedianet.socketserver.SocketClient client, bool bSuccess, string strErrors)
{
IsXmppSuccess = client.Connected;
}
void xMPPClient_OnStateChanged(object sender, EventArgs e)
{
switch (ObjXmppClient.XMPPState)
{
case XMPPState.Ready:
if (IsXmppSuccess)
{
this.Dispatcher.BeginInvoke(() =>  //ERROR HERE-
widows.ui.core.core dispatcher does not contain adefinition for BeginInvoke and no extension methode BeginInvoke accepting a first argument of type windows.ui.core.core dispatcher could not find(are you missing a using directives or assembly refference?)
{
Frame.Navigate(typeof(Logedin))
;
});
}
else
{
this.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Check server name/IpAddress");
return;
});
}
break;
case XMPPState.AuthenticationFailed: this.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Enter valid username and password");
//NavigationService.Navigate((new Uri("/Output.xaml?key=wrong", UriKind.Relative)));
return;
}); break;
}
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
}
}
 

Answers (1)