Tag Archives: async

Do NOT cache SSL certificates on the client side – How to post XML asynchronously and read the response using HttpClient in c#

I had one hell of a day yesterday. The evening before, I’d renewed the certificate on a WCF service of ours, because the old one was about to expire. After renewing it, I tested the service to confirm that I … Continue reading

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

Shared stuff updated

No new code shared, I’m afraid, but I have continued to update my image that I use for a custom logon background in Windows 7 (which I am still using at work). The feature does not work in Windows 8, … Continue reading

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

Caching in a desktop application using ObjectCache and LocalDB

Last Wednesday I decided to convert my application’s caching from a file-based cache to a database-based cache implementation, mostly to try out LocalDB, which I had never used before. Unfortunately, due to power outages after that, I could only test … Continue reading

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

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

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

Async Tasks and cancellation – Not always so easy

A while ago, I explained briefly how I asynchronously populate and cancel thumbnails in the file browser form of my application. But cancellation turned out to be more difficult than I initially thought. That is, if I changed the current … Continue reading

Posted in Programming | Tagged , , , | Leave a 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

Async all the way – No way!

I was just reading an article by Stephen Cleary on best practices in async code. I haven’t fully composed my thoughts on this topic, but this has been on my mind for a while, so I will publish it anyway, … Continue reading

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

Using async code (with await) in .Net 4.0

Recently I needed to add a UI for marketing folks here to be able to edit some pages that are presented to players on logging in to the online casino. The pages show featured promotions, games and so on. So … Continue reading

Posted in Programming | Tagged , , , | 2 Comments

Using RegionErate in Visual Studio 2012

Being a creature of habit, I have been using a Visual Studio addin called RegionErate to organize my code for several years now. It works very well up to Visual Studio 2010, which doesn’t help me since I have been … Continue reading

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

Some Extension Methods

Extension methods are, in my opinion, one of the best additions to the C# language. I’d been out of track with the various language improvements of the last few years, due to various reasons. (Playing with the language and trying … Continue reading

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

Icon Files in c# – Part 2. Writing icon files

Welcome to part 2 of my c# icon file handling code. This one is about my IconFileWriter. Again, the source, for this and a whole bunch of other stuff, is here: RomyView.zip To be honest, I didn’t spend much time … Continue reading

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

C# Application to import paradox data to SQL Server

As promised… When recently tasked with rewriting an antiquated hotel reservation booking system, that uses paradox data, into C#, I was disappointed to find no free tools online that can import the paradox tables into SQL Server. Thus to save … Continue reading

Posted in Programming | Tagged , , , , | 12 Comments

Timing methods in c#, updated

In my previous post on this topic, I did mention that it wasn’t about the code, but the concept. Still, I wrote that code a while back and only really used it that one day. For the code I timed … Continue reading

Posted in Programming | Tagged , , | 1 Comment

Concurrent asynchronous processing of all the files in a directory with support for cooperative pausing, in C#

The other day Stephen Toub of MSFT published a blog on cooperative pausing async methods. It’s an awesome post, and a much better way of pausing in async methods than what I was doing (which was a loop where I … Continue reading

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

A C# Windows Forms application that allows only one instance

A common requirement for application developers is an application that allows only a single instance. I can still remember the first time it came up for me. That was way back in the year 1999 – and I was a … Continue reading

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

Timing methods in c# to see which implementation is faster

Update. Don’t use the method timing code posted here. A newer and much better version is here. I have been working on a “pet” project in c# for the last three years now… It’s an image viewer, video player (DirectShow), … Continue reading

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