Find examples of code, tutorials, and walkthroughs! When discussing programming and software engineering topics, examples are critical!

Tasks, BackgroundWorkers, and Threads – Simple Comparisons for Concurrency

(This article is intended to be a spiritual successor to this previous entry, and now includes Tasks!) Even if you're new to C#, you've probably come across at least one of Tasks, Threads, or BackgroundWorkers. With a bit of additional time, it's likely you've seen all three in your journey. They're all ways to run concurrent code in C# and each has its own set of pros and cons. In this article, we will explore how each one operates at a high level. It's worth noting that in most modern .NET applications and libraries you'll see things converging to Tasks. The Approach I've gone ahead and created a test application that you can find here. Because this is in source control, it's possible/likely that it will diverge from what we see in this article, so I just wanted to offer…

0 Comments

Xamarin Forms – Jumpstart Your App With Autofac

I love dependency injection frameworks ever since I started using them. Specifically, I'm obsessed with using Autofac and I have a hard time developing applications unless I can use a solid DI framework like Autofac! I've recently been working with Xamarin and found that I wanted to use dependency injection, but some of the framework doesn't support this well out of the box. I' was adamant to get something going though, so I wanted to show you my way to make this work. Disclaimer: In its current state, this is certainly a bit of a hack. I'll explain why I've taken this approach though! In your Android projects for Xamarin, any class that inherits from Activity is responsible for being created by the framework. This means where we'd usually have the luxury of passing in dependencies via a constructor and…

2 Comments

Using Autofac With Unity3D

Why Consider Using Autofac With Unity3D? I think using a dependency injection framework is really valuable when you're building a complex application, and in my opinion, a game built in Unity is a great example of this. Using Autofac with Unity3D doesn't need to be a special case. I wrote a primer for using Autofac, and in it I discuss reasons why it's valuable and some of the reasons you'd consider switching to using a dependency container framework. Now it doesn't need to be Autofac, but I love the API and the usability, so that's my weapon of choice. Building a game can result in many complex systems working together. Not only that, if you intend to build many games it's a great opportunity to refactor code into different libraries for re-usability. If we're practicing writing good code using constructor…

2 Comments

What Makes Good Code? – Should Every Class Have An Interface? Pt 2

Should Every Class Have an Interface? This is part two in the sub-series of "Should Every Class Have an Interface?", and part of the bigger "What Makes Good Code?" series. Other Peoples' Code So in the last post, we made sure we could get an interface for every class we made. Okay, well that's all fine and dandy (I say half sarcastically). But you and I are smart programmers, so we like to re-use other peoples' code in our own projects. But wait just a second! It looks like Joe Shmoe didn't use interfaces in his API that he created! We refuse to pollute our beautiful interface-rich code with his! What can we do about it? Wrap it. That's right! If we add a little bit of code we can get all the benefits as the example we walked through originally. It's…

1 Comment

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

Controlling a Myo Armband with C#

Background Thalmic Labs has started shipping their Myo armband that allows the wearer's arm movements and gestures to control different pieces of integrated technology. How cool is that? My friend and I decided we wanted to give one a whirl and see what we could come up with. We're both C# advocates, so we were a bit taken back when we saw the only C# support in the SDK was made for Unity. We decided to take things into our own hands and open source a Myo C# library. We're excited to introduce the first version of MyoSharp! The underlying Myo components are written in C++, and there's only several functions that are exposed from the library that we can access. In order to do this, we need to leverage platform invocation (PInvokes) from C# to tap into this functionality. Once you…

16 Comments

Python, Visual Studio, and C#… So. Sweet.

Python & C# - Background Let's clear the air. Using Python and C# together isn't anything new. If you've used one of these languages and at least heard of the other, then you've probably heard of IronPython. IronPython lets you use both C# and Python together. Pretty legit. If you haven't tried it out yet, hopefully your brain is starting to whir and fizzle thinking about the possibilities. My development experiences is primarily in C# and before that it was VB .NET (So I'm pretty attached to the whole .NET framework... We're basically best friends at this point). However, pretty early in my career (my first co-op at Engenuity Corporation, really) I was introduced to Python. I had never really used a dynamic or implicitly typed language, so it was quite an adventure and learning experience. Unfortunately, aside from my…

15 Comments

End of content

No more pages to load