如何執行這2個操作成爲1操作?其實我在後臺代理中使用,但第二個操作不能執行,不能得到的價值。任何想法?如何在1個阻塞呼叫中執行操作?
public void running()
{
ServiceReference1.WebServiceSoapClient test = new ServiceReference1.WebServiceSoapClient();
test.ReadTotalOutstandingInvoiceCompleted += new EventHandler<ServiceReference1.ReadTotalOutstandingInvoiceCompletedEventArgs>(serviceClient);
test.ReadTotalOutstandingInvoiceAsync();
}
public void serviceClient(object sender, ReadTotalOutstandingInvoiceCompletedEventArgs e)
{
answer = int.parse(e.Result.ToString());
}
更新: 在後臺代理:
VibrateController testVibrateControl = VibrateController.Default;
public int answer;
protected override void OnInvoke(ScheduledTask task)
{
//TODO: Add code to perform your task in background
running();
ShellTile t = ShellTile.ActiveTiles.First();
StandardTileData d = new StandardTileData()
{
Title = "U have " + answer + " Invoice!!",
BackTitle = "How Are You!!",
//Count = 0,
// BackBackgroundImage = new Uri("dog.jpg", UriKind.Relative),
// BackgroundImage = new Uri("untitled.png", UriKind.Relative)
};
t.Update(d);
testVibrateControl.Start(TimeSpan.FromSeconds(3));
testVibrateControl.Stop();
//ShellTile.Create(new Uri("/MainPage.xaml?pp=cas", UriKind.Relative), d);
NotifyComplete();
}
在主頁:
private void CheckBox_Checked_1(object sender, RoutedEventArgs e)
{
try
{
PeriodicTask p = new PeriodicTask("jj");
p.Description = "Don't push the red button";
ScheduledActionService.Add(p);
//ScheduledActionService.LaunchForTest(p.Name, TimeSpan.FromSeconds(2));
#if (DEBUG_AGENT)
ScheduledActionService.LaunchForTest(p.Name, TimeSpan.FromSeconds(2));
#endif
}
catch (Exception ex)
{
}
}
你能否提供一些背景知道爲什麼你想讓它成爲阻塞呼叫?它可以幫助人們選擇可能的解決方案。 (如果不小心的話,它可能會導致界面無響應。) – lzcd 2013-03-12 00:33:30