How do I add a method reference as a parameter?


(mtiede) #1

I have this code:

  webrequest := HttpWebRequest( webrequest.Create( ub.Uri ) );

  webrequest.Method    := 'POST';
  var requestStream: Stream := await Task.Factory.FromAsync( webrequest.@BeginGetRequestStream, webrequest.@EndGetRequestStream, nil);

But that doesn’t compile. How DO I pass the webrequest’s BeginGetRequestStream to the Task Factory?


(Patrick Lanz) #2

Mark,
@ webrequest.BeginGetRequestStrem, no?


(mtiede) #3

Yes, that sort of works. I tried that first, but it complained about mismatched case, but that was just a warning I mistook for an error.

However, it turns out, that I can’t even use the “await”, apparently because it is Silverlight app.

The error message now says, “await requires .net 4.5 or later”. I think that is what I’m using, but maybe I better double check that.

… time passes …

I double checked. There doesn’t appear to be a place to select .net version 4.5. Only Silverlight 5.

… more time passes …

hmm… I see C# examples in SL 5 using await. I even added the System.Threading.Tasks namespace, but still got the compiler error.


(Carlo Kok) #4

I’ll log a bug and see if it’s doable to support SL5 with await.


(RemObjects) #5

Thanks, logged as bugs://74261


(mtiede) #6

I’m not positive the examples I saw earlier were with Silverlight. My SEARCH included Silverlight, but perhaps the found page was not for Silverlight. OR, whoever wrote the example code did not actually try it.

So I’m not sure how much you can really do with Silverlight.


(RemObjects) #7

bugs://74261 got closed with status wontfix.


(Carlo Kok) #8

Silverlight has pretty much died :frowning:


(Patrick Lanz) #9

Carlo,
it’s at the end of its life, but still used.
The functions of my Silverlight applications are migrating slowly to a web application and a WPF application
So, we need support for it under VS2015. Not new features, but just the ability to edit, compile and debug.


(Carlo Kok) #10

Of course we’re not removing SL support. However I’m not adding new features to the compiler that are specific to silverlight.