Below are my raw notes during the “What’s New in .Net 4.5?” session at CodeStock 2012 on Friday, June 15th at 1:50 PM / 70 min. This session was hosted by Layla Driscoll from Microsoft. She’s on the Silverlight CLR team.
Click here to follow me on Google+.
Follow me on Twitter @CSharpner.
And below are my crude, raw notes taken during the session, only minimally cleaned up.
This sample will use:
- Async & await
- Asplnet web api
- Entity framework
Creating a Metro app
- Multiple tiles
- Drill down into them for more stuff.
- Using some sort of MVC type of development. (Really? For a DESKTOP app??!?! I’d heard of this, but that’s the LAST way I want to develop a DESKTOP app… you get the worst of both worlds… no advantages of a native app and no advantages of web deployment and all of the frustrations of both. Though, it’s cool you CAN do it… I’d just never do it that way.)
- Looks like it’s a web app, but it’s a Metro app.
- Controllers are deriving from ApiController
- Type called Feature.
- (Note, code snippet below is incomplete. Remember, I typed this in “class” as fast as I could…)
public class FeaturesController: ApiController { private Feature[] features - {{new Feature{Id=1,Name="LINQ"}, new Feature{Id-2,Name="OptionalParam"}}; public Ienumerable<Feature> Get() { return features; } //Feature is her own plain old class with several fields in it. public Feaure Get(int id) { var feature = features.SingleOrDefault(f=>f.Id=id); If (feature == null) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound); Response.Content = new StringContent("Feature not found"); throw new HttpResponseException(resp); } return feature; }
Async keyword can be placed on methods like
private async void blah() { using (var httpClient = new HttpClient() { httpClient.MaxResponseContentBufferSize = 1024*1024; var response = await httpClient.GetStringAsync("http://localhost blah blah"); var list = JsonConvert.DeserializeObject<List<int>>(response); foreach(var I int in list) { response = await httpClient.GetStringAsync("http://localhost blah blah" + i); var f = JsonConvert.DeserializeObject<FeatureDataItem> }
- Use nonvolatile for locking code. (or did she say non-locking?)
- Win32 API (or whatever it’s called now) looks like managed code… no DLL import crap.
- New large object heap. Anything 85,000 bytes.
- Multi-core JIT
- Prefetcher
- ReadOnlyDictionary