Tag Archives: C#5

Updates to my shared code

I’ve made several updates to my shared code, and the files in that share. I don’t think any of them justify an exclusive post for themselves, so I’m devoting this post to all of them (that I can remember) instead. … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment

My Parallel TaskScheduler revisited

Recall my post A configurable TaskScheduler that can be changed by the user at runtime… Yesterday I used ILSpy (I don’t use Reflector because it is no longer free) to disassemble the built-in ThreadPoolTaskScheduler class, just out of curiosity. Some … Continue reading

Posted in Programming | Tagged , , , | Leave a comment

How to start an external process that is associated with a file type, and bring it’s window to the front, in C#

I found a number of answers regarding how to do this online, but none worked exactly the way I wanted. This is because I actually have one extra requirement. That is, if the file type does not have an associated … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment

Putting it all together – Configurable TaskSchedulers that can be changed by the user at runtime

This will be my last post about TaskSchedulers and TaskFactories. It will be easier to understand this post if you have read my previous entries on implementing a custom TaskScheduler, but that is not a requirement, as all the relevant … Continue reading

Posted in Programming | Tagged , , , , , | 1 Comment

Diving deeper into the TaskScheduler work item pool

Two days ago, I spent my hours of insomnia thinking about the question: Just how parallel is my ParallelTaskScheduler custom TaskScheduler implementation, really? It divides its work items into batches (of Task objects), and then process each batch’s items in … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment

A sneaky little critter of a bug and I forget to use common sense to debug

Last night, I decided to put my code of late (the custom TaskScheduler and the pattern I’ve come up with using several TaskScheduler implementations) through some more rigorous testing. Imagine my surprise when a nasty bug showed up right away… … Continue reading

Posted in Programming | Tagged , , | Leave a comment

More thoughts on TaskSchedulers and TaskFactories

I would never have expected it, but it seems that in my application, the custom TaskScheduler I came up with the other day actually performs so well that I now use it as the default in most places. That is, … Continue reading

Posted in Programming | Tagged , , , | Leave a comment

Getting more advanced knowledge is difficult

There was an annoying bug in my RomyView application the other day, a bug that caused what is in my mind, the worst kind of situation when it comes to asynchronous code: My code that populates a thumbnail cache item … Continue reading

Posted in Programming | Tagged , , , | Leave a comment

Calling async methods from properties

I noticed that yesterday, someone read my post on Cancellation after searching the web to find out how to call async methods from properties. I am no expert on async code; I’ve just been playing with it for a while … Continue reading

Posted in Programming | Tagged , , | 1 Comment

Spot the bug! An example of how to use the TaskCompletionSource<TResult> in C#

I have a habit of making several unrelated changes to projects around the same time. That works out fine in a controlled environment, like at work where there is source control, but it’s not so cool at home where I … Continue reading

Posted in Programming | Tagged , , , | 1 Comment

Reliably asynchronously reading and writing binary Streams in c# (Always check method call return values)

Every so often, I get brutally reminded not to think I am too clever. Indeed, one thing I’ve learned as a developer is that there is always more to learn, and I should be humble, because tomorrow, I will learn … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment

How to download a file with HttpClient in c#

Microsoft recently released a prelease of HttpClient in a portable library via Nuget. But it seems that many developers do not know how to use it. Again, the source, for this and a whole bunch of other stuff, is here: … Continue reading

Posted in Programming | Tagged , , , | 3 Comments

Having an async Task yield to the Windows Forms SynchronizationContext

There are issues with calling Task.Yield in Windows Forms, as explained by Stephen Toub on this forum post. Interestingly, I have the opposite problem to the guy complaining there. I have lots of async code, much of which frequently switches … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment

Updating the Windows Forms UI from async threads

There are many ways to update your UI from async ThreadPool threads. This is just one of them; my preferred way of doing so. These are my general purpose methods, in my base form class, for updating the UI from … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment

Creating an asynchronous timer

Here’s some interesting code I thought I might share. It’s an asynchronous timer, and allows you, in Windows Forms, to have a simple timer where you specify an interval, a condition, some code to execute on the interval, and optionally … Continue reading

Posted in Programming | Tagged , , , | Leave a comment