Inline assembly in C#
I was working on trying to figure out how sqeeze out some more speed for some calculations, which involved the following bit of math.
I was working on trying to figure out how sqeeze out some more speed for some calculations, which involved the following bit of math.
The TPL is great but sometimes you have to work within a framework which schedules background tasks for you without giving you access to a Task of some kind. I had a situation like the following 1 2 3 4 5 6 7 8 private void DoSomeWork(CancellationToken token) { token.ThrowIfCancellationRequested(); // do lots of work } // some other code that might happen in a UI thread AsyncWorkScheduler.Schedule(()=> DoSomeWork(token)); I didn’t really have access to how the background task was scheduled, and to be honest I didn’t really care. What I needed was a way to wait for the work to finish, whether it finished by itself or if it was cancelled via the CancellationToken. I wanted to use await to avoid blocking any UI threads as well. ...
The task was simple. I have data on disk where the file sizes varied from 1kb to a couple of gigs. I needed to process the data and return the points from a method that returns an IEnumerable. The specific data file has a custom format, so I had to use a custom API to read the data. There was no async I/O option available unfortunately. Sounds simple enough. Here is my first version. I replaced the custom API with a simple file read operation. As with the custom API, I read pairs of data in block sizes I can specify. ...