Grokking ContextAwareResult (.Net internals)

(This is the sequel to grokking LazyAsyncResult, which could be considered a prerequisite.) You’ll see if you look through Socket async API internals that they aren’t just using the LazyAsyncResult class, they’re actually calling this thing called ContextAwareResult (and so are a few of the other .Net network async APIs). What is this beast? The…

0

Grokking LazyAsyncResult (.Net internal)

(Background: sometimes as I try to understand our bugs, I have to learn about the .net internal classes used for implementation of the public classes that we’re consuming – my motivator today is SocketAsyncEventArgs.) Today I’m going to try to understand the internal class LazyAsyncResult. Now that .Net core is open source we can find…

0

Slimming down your build – don’t copy the intellisense files!

So you know how a lot of nuget packages include intellisense XML files and they get copied to your output binaries folder during build? I did a quick web search but soon for how to fix this, but soon gave up and resorted to searching my msbuild .targets files instead. Finally I found it. The…

0

Is Autofac magical – part II

Now that you’ve read part I perhaps you can answer this. What does this code do?     class FO : IEnumerable    {         public IEnumerator GetEnumerator()        {            throw new NotImplementedException();        }    }     class Program    {        static void Main(string[] args)        {            var cb = new ContainerBuilder();            cb.Register(ctx => new FO()).As<IEnumerable>().InstancePerLifetimeScope();            cb.Register<Func<FO>>(ctx => { return ()…

0

Is Autofac magical?

The answer is yes! OK let me explain. I never registered anything as Func<IObservable<object>> and yet the below code still works. It turns out to be that not only does autofac understand Func<Dependency>(), it understands a whole bunch of things that you may or may not have intended to be dependency relationships. 🙂 The details…

0

Distilling some ideas for keeping that data access code (and test code) tidy…

I just spent a while doing some refactoring. It turned out to be a very long while, probably much more than I would have originally estimated. (Part of the reason for that is builds and tests that take a long time…) The changes I made were somewhat haphazard at first, and I wasn’t sure why I thought…

0

Request and connection throttling when self hosting with OwinHttpListener

[Disclaimer before we begin: I’m not really an expert on OWIN (henceforth ‘owin’) or HttpListener – I just researched this as best I could myself so I may get some stuff wrong. Question my authority!] Self-hosting a web server using owin instead of using IIS is an attractive option to me partly because of the…

0

Exploring F# (1)

C# and typescript are starting to feel too familiar and dull, so I went exploring. I fired up my first F# console app, and learned a few things. I’m taking a very lazy almost-but-not-quite-just-in-time approach to learning where I ask newbie stack overflow questions as I go along whenever I can’t find the answer with…

1

Everything but the language design…?

So I’ve been reading some history of programming languages. And one question that came up a lot is ‘What made this language popular? Why did it live, where others have failed?’ There have been a bunch of different answers, for different languages, and they don’t really have much to do with language design. And it…

0

Reading performance counter data in .NET

Nothing you can’t easily write yourself, but while playing around, I wrote this one myself, and learned one or two things. Firsltry, it demonstrates the wrinkle that when reading % processor time you need to specify the instance name of the processor, or the special instance name “_Total”. Secondly you’ll notice that the % CPU…

0