C# Dev Connect 1 – Intro To Threading

C# Dev Connect 1: Intro to Threading In my last post, I mentioned we'd be hosting a C# Dev Connect meetup at our Magnet Forensics HQ in Waterloo. I figured I'd post to talk about how the event went so that if you couldn't make it, you'll have an idea for next time (and if you did make it, maybe you can comment on how you thought the event went). Our first Dev Connect was lead by a colleague of mine, Chris Sippel, who wanted to give a talk on threading basics in C#. Threading can quickly become a really complex topic, so Chris wanted to keep it high level and talk about the different approaches you can use to start threading in your C# applications. https://twitter.com/Chris_Sippel/status/557655585492328450 Dev Connect: Before the Talk Before Chris gave his talk on threading, we…

0 Comments

First C# Dev Connect is Coming Up

  C# Dev Connect Meetup! About a year ago I had thrown around the idea of creating a C#-specific group that would meet at a regular interval with some of my colleagues. I saw that there was interest, but between all of the things we had going on in our personal lives and work lives, we just hadn't been able to co-ordinate something. I'm excited to announce that with some more solid planning over the last couple of months, C# Dev Connect will be able to host their first meetup! The company I work for, Magnet Forensics, has graciously offered our new office to host the event which will help tremendously. We'll have a group of people from Magnet Forensics their to help out, but the only thing "Magnet" about the event is really just that it's hosted at the office. What's…

0 Comments

Simple Way To Structure Threads For Control

BackgroundI've previously discussed the differences between the BackgroundWorker and Thread classes, but I figured it would be useful to touch on some code. I'd like to share the pattern I commonly use when creating threads in C# and discuss some of the highlights.The Single ThreadI like to use this design when I have a single thread I need to run and in the context of my object responsible for running the thread, I do mean having a single thread. Of course, you could have your object in control of multiple threads as long as you repeat this design pattern for each of them.Here's the interface that I'll be using for all of the examples: internal interface IThreadRunner { #region Exposed Members void Start(); void Stop(); #endregion }Behold! internal class SingleThreadRunner : IThreadRunner { #region Fields private readonly object _threadLock; private…

0 Comments

Thread vs BackgroundWorker

Background There are two classes available in the .NET framework that sometimes have some confusion around them: The Thread and the BackgroundWorker. They're both used to do some heavy lifting for you on a separate thread of execution (so you can keep on keepin' on), so why do we have two different things to accomplish the same end result   Enter The Thread Class The Thread class is available in the System.Threading namespace. Surprising, right? It's the basic unit for spawning off work to be done. Threads let you provide them with a name, which could be one advantage to using them. A thread can either operate as "background" which means it will be killed when the application exists, or not as background, which will actually keep the application alive until the thread is killed off. An instance of the…

0 Comments

End of content

No more pages to load