2

I try to use Async with Portable Class Library. I use Profile 104, which includes:

  • .NET 4.5
  • Silverlight 4
  • WP 7.5
  • WinRT

Installation works and I can use System.Threading.Tasks but I can't compile because I have this error:

Cannot await System.Threading.Task<System.Net.HttpWebResponse>

On the line with await in this sample:

public async Task<string> GetAsync(string urlToCall)
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlToCall);
    request.Method = HttpMethod.Get;
    HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
    using (var sr = new StreamReader(response.GetResponseStream()))
    {
        return sr.ReadToEnd();
    }
}

Why?

Update

My profile 104 is update with monodroid and monotouch I use NuGet to install Microsoft.Bcl.Async v 1.0.16 If I add AsyncBridge.Portable v 0.2.0 I have no warning of Visual Studio, but it doesn't compile. There are conflicts between this 2 libraries in System.Attributes

How make working this libraries together ?

Thanks

4

1 回答 1

2

我使用了来自 Nuget 的 Bcl.async 和 AsyncBridge.Portable,但我遇到了错误。

如果我使用来自 Nuget 的 Bclasync 和 Daniel Plaisted 创建的 AsyncBridge.Portable 就可以了。

我很想知道丹尼尔在做什么来制作这个库?

谢谢,

于 2013-03-11T08:42:57.663 回答