Jump to content

  • Log In with Google      Sign In   
  • Create Account






Slow progress...

Posted by phantom, 09 May 2012 · 494 views

C# Tasks LINQ
Not a great deal to report from the front; having spent a few hours on trains over the weekend I've managed to chew into the DLR book I have a fair chunk. It is slow going but progress is being made in my head which is nice.

Most of my time at work has been spent working on our new data build pipeline (I am a rendering coder, honest!) which has let me do something I've been wanting to do for some time and really stretch my wings a bit with C# and .Net4.

Over the last few weeks I've come to love the whole Task system in .Net 4 so much so that, after some initial resistance from those who didn't know about them in general, I've managed to convince the other guys working on it that using Tasks as the basis of the build system is the way forward. It isn't a strict task system; asset processing rules themselves get launched as 'long running' tasks which means they get a new thread, as to tasks which kick off an exe to do some processing however the ability to just throw work around and know that it'll get done and back to you does make coding quite relaxing.

It isn't completed yet however it is already leaps and bounds better than our old python build system (a pox on the GIL!) and has afforded me a nice chance to learn somethings.

In fact today, while converting some build rules from Python to C# I took the time to dive into LINQ too, which I've always liked the look of but never had a chance to try. It has made parsing XML files and pulling out data MUCH saner so yeah, pretty much in love with that too... so much so I want to revisit some already converted rules armed with this new knowledge :)

So, if you haven't got around to it already I would urge you to have a play with the Task system in .Net and the LINQ stuff; an afternoon of learning and playing around adds a couple of extra useful tools to your skill set.




The TPL makes asset management a complete breeze. Pretty much any kind of concurrent programming is just gloriously easy to do in C# these days. All the synchronization primitives, lockless collections, and various ways to asynchronously run tasks just makes that traditionally painful multithreaded programming job much easier. Just wait until you get into the new async/await features.

You're a little late to the party though with LINQ. They've got a new experimental library in the works called Reactive Extensions that turn the "pull" concept of iterators on its head for "push" style event-based stream processing. It requires a whole different way of looking at things, but it lets you write some very intuitive code once you wrap your mind around it. I've been thinking about how to apply it to entity systems in a game.
Yeah, TPL is pretty damned awesome; I was considering pushing for the async/await CTP to use but upon looking at how we are using tasks and how the Async stuff is structured under the hood I'm not sure it would be as useful for us. Plus getting a CTP approved might be a pain and it'll also make me unpopular with future rule writers/system users ;)

And yeah, a little late to the LINQ party but that's the down side of spending most of your time knee deep in C++ code - that's why I'm glad to get a chance to stretch my C#/.Net wings a bit right now.

I have heard of Reactive Extensions; some time back I was listening to a podcast about them (few years I think in fact) and they sounded pretty cool but as I've been out of the .Net loop for a while they haven't been on my radar - don't know how much use they would be for this project, based on my vague knowledge, but it's something to think about for other things/going foward.

Recent Entries

Recent Comments

PARTNERS