Browsing 7239 questions and answers with Jon Skeet
You could check whether the method underlying the delegate you've been passed is annotated with the AsyncStateMachineAttribute - but to be honest, I wouldn't. It's just asking for trouble, using an implementation detail like... more 10/17/2013 8:55:16 PM
You can make it generic, certainly: static void Benchmark<T>(Func<T> function, int iterations) You might also want to overload it to accept Action, for void methods. more 10/17/2013 8:09:28 PM
You'd run it as: java One.Test ... but from the root directory (basic), not from the One directory. You always specify the fully-qualified class name. Oh, and package names in Java should be lower-case, so it should be one and... more 10/17/2013 5:29:43 PM
You're nearly there at the end - you just need to enclose the lambda expression in () as it's a method argument. You also need to use the return value from makeAttempt to provide a return value for your getNextMessage method. So: public... more 10/17/2013 5:02:04 PM
Well, this code would be simpler, if you're using .NET 4 or later you can use File.ReadLines: foreach (var line in File.ReadLines()) { // Do something } Note that this is not the same as ReadAllLines, as ReadLines returns an... more 10/17/2013 4:27:33 PM
Well if the constructor fails, the exception will be thrown instead of the reference being returned - so the calling code has nothing to dispose. Basically, constructors need to be careful. If an exception is thrown in an exception, the... more 10/17/2013 4:25:14 PM
As far I know, String is a immutable class. (refer to the javadoc), so, if I implement a method to receive such output, I may have many objects being created because of my concatenations: Nope. As you're performing all the... more 10/17/2013 3:09:42 PM
It's compiling because you haven't got Option Strict on. If you turn on Option Strict (which IMO you should pretty much always do) it won't compile - your function isn't compatible with either ThreadStart or ParameterizedThreadStart. If... more 10/17/2013 3:07:58 PM
Well presumably the HTTP status code is 404. You're already accessing the response in your error code though - all you need to do is try to parse it as JSON, just as you are in the success case, instead of using we.Message to show an error... more 10/17/2013 2:33:52 PM
This is the problem: var request = (HttpWebRequest)WebRequest.Create(@"https://accounts.google.com"); That's not the URL you showed originally. That's just the domain root. You need: var request =... more 10/17/2013 1:26:26 PM