English 中文(简体)
首先,由于原因不明,要求等待的超常职能是同步的。
原标题:First call to await-able asynchronous function is synchronous for unknown reason

目前,Im与WPF 4.5和视觉演播室11级演播室进行节目审查。 I m 采用Aync-await手铐,在申请活动中按时间顺序进行检索。 问题在于,首先需要等待使用的方法使申请在完成之前就read。 其后所有电话都是有价的,即,虽然它们重新履行申请仍可使用。

这里是我的法典(只有有意义的摘录):

XAML

<toolkit:AutoCompleteBox FilterMode="None" 
                         Margin="5,0,5,0" 
                         x:Name="textArrival" 
                         Populating="textArrival_Populating"
                         SelectionChanged="textArrival_SelectionChanged"/>

C# Code-behind:

private async void textArrival_Populating(object sender, PopulatingEventArgs e)
        {
            e.Cancel = true;
            textDeparture.ItemsSource = await model.ProcessStationRequest(textArrival.Text); 
            textArrival.PopulateComplete();
        }

前几部法典的等待呼吁来源:

public async Task<object[]> ProcessStationRequest(string request)
        {

        // omitted: preparing the request into MemoryStream outputStream
        // ...    

        HttpResponseMessage response = await httpClient.PostAsync(hostName, outputStream);

        // omitted: parsing the XML response to an object responseContainer 
        // and returning its member Items, which are of type object[] 
        //...

        return responseContainer.Items;

        }

当Im debugging和在行程后确定休息点时,httpClient。 邮政管理处 我看到,它真的是在处理申请时放弃我的申请(大约2秒)。 但是,如果我把我的左点右线放在可等待的电话线上,就会在汽车箱开始使用之后立即发生。 我的法典中至少没有这样的说法,这就是为什么我假定它会等待到httpClient,使我 app。

您能否在这个法典中提出造成这种奇怪行为的一些问题?

最佳回答

你也许会重新进入一个以<代码”为标题的已知问题。 HttpWebRequest。 该物体上的“同步”方法实际上(完全)并非同步。

现在,我建议将<条码>PostAsync列入<条码>。

I ve

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签