Browse by Tags

All Tags » Source Code (RSS)

How does Stopwatch work

I’ve been using Stopwatch (and blogged about it ) for some time and it never occurred to me to check how it really works. When using it as a benchmarking tool the fact that perhaps it wasn’t as accurate as can possible be didn’t bother me at all. The question of the accuracy of Stopwatch become relevant in one of my pet projects, I needed a high precision timer and I wanted to know if it was up to the task. Investigating Stopwatch proved to be very easy – using Reflector and I’ve opened System.Diagnostics...
Posted by dhelper | with no comments

Virtual Tech-Days recordings available

Microsoft Tech-Days recordings are available for viewing and download on the Tech-Days site . So if you’ve missed the my session on TDD & Mock objects it is available for download (or Online viewing). The session I gave on TDD and Mock objects is available here . The presentation (.pptx) Code examples from the session – you will need Typemock Isolator download an evaluation from this site .   I would appreciate any feedback – please feel free to leave comments or send an Email

Presentation from .NET Software Architects User Group

Yesterday I co-delivered a lecture about Unit testing titled "How to benefit from unit testing in the real world" at the monthly gathering of the .NET Software Architects User Group. I'd like to thank Doron that presented the 2nd part of our lecture and give thank to an esteemed member of our development team - the build bunny. We had a good turnout (50+ people) that came to hear about TDD and Unit Testing. The presentation went well with only one notable incident (the movie we had...

Three different ways to throw events in C#

The Event model in C# finds its roots in the event programming model that is popular in asynchronous programming. The basic foundation behind this programming model is the idea of "publisher and subscribers." In this model, you have publishers who will do some logic and publish an "event." Publishers will then send out their event only to subscribers who have subscribed to receive the specific event. In C#, any object can publish a set of events to which other applications can...

How-to Render managed (.NET) form using native DirectX

Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia , especially game programming and video, on Microsoft platforms. Although a managed DirectX exist some of the time you need the power of C++ when using it. In the past I used DirectX with C++ for image processing and video both needs a lot of byte operations and pointer arithmetic that I could not do in C# (due to performance considerations) But I wanted to create the application...

New StackOverflow Notifier Released

This is a maintenance release until I finish the new features I’ve promised. Changes: Added Proxy Support so that users behind firewall can use SO-Notifier. I’ve done a few changes to reduce the bandwidth overhead of the application.   As suggested by Jeff Atwood I’m using gzip http header specified to reduce network bandwidth. It took me a while to discover how to it. Finally I came up with this code to retrieve the user web page: public static string GetStringFromURL(string urlString, IWebProxy...

StackOverflow Notifier

Update: New version has been released in case you're using the last version (V1.0.0.0) please use this version instead . In case you don't know what StackOverflow is all about you can read about it At the site's About Page : Stack Overflow is a programming Q & A site that's free . Free to ask questions, free to answer questions, free to read, free to index, built with plain old HTML, no fake rot13 text on the home page, no scammy google-cloaking tactics, no salespeople, no JavaScript...
Posted by dhelper | 7 comment(s)
תגים:, ,

Why should I use List<T> and not ArrayList

I came upon a questing at StackOverflow : The system I work on here was written before .net 2.0 and didn't have the benefit of generics. It was eventually updated to 2.0, but none of the code was refactored due to time constraints. There are a number of places where the code uses ArraysLists etc. that store things as objects. From performance perspective, how important change the code to using generics? I know from a perfomance perspective, boxing and unboxing etc., it is inefficient, but how...

Why Atomic operations are not always thread safe

A question I saw on StackOverflow : Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true ; //... same for a read if (_bar) { ... } } This question was answered quickly by several users that quoted C# spec , similar posts and the holy bible (ok maybe not the holy bible :) ). The answer given was that reading or writing a boolean value is atomic (as well as other basic...

SharpPDB - .NET Class that reads and writes palm OS files

I'm the proud owner of a Palm Tungsten E2 device. It's amazing how this old device is still much better then newer mobile windows devices. It has great battery life, quick response time and easy to use PIM. And it seems I'm not only one that thinks so - you can read about it download squad - Pokin' to the oldies: why Palm OS 5 still rocks About a year ego I needed to sync between an application I had on my PC to an application on my Palm device and so I've written a library in...
Posted by dhelper | with no comments

Using Managed Thread Local Storage

At work we needed to keep information about each thread. Due to application's nature we couldn't know when a thread would call our code and to make things more interesting we couldn't even rely on the thread id for unique identification. Because of those restrains an external data structure was out of the question and we needed to find a way to store that data in the thread itself. Luckily .NET Thread has the ability to store data on the thread itself using DataSlots: To Save Data from...
Posted by dhelper | with no comments

How to find assembly path ,name and version at runtime

Ever needed to find the location of your executable in runtime? what about getting a certain dll name? Look no further - the following is a quick overview on the .NET objects and functions that can solve your problem. Application.ExecutablePath System.Windows.Forms.Application has static methods and properties that help manage an application, as well as properties to get information about an application. What It can do : Get the path (and name) of the current running application How : Finding the...
Posted by dhelper | 1 comment(s)
תגים:, , ,