• About
  • Privacy Policy
  • Utilities
Darchuk.NET

Asynchronous

Testing Observables in Angular >= 6.0.0

August 17, 2018 by Robert Leave a Comment

In a previous post I talked about testing Observables in your Angular code.  This is pretty common, because HttpClient sends back an Observable<T> – so if you want to spyOn that function, you’ll need to figure out how to return an Observable. I’ve been bouncing around a couple of projects/repos recently, and it turns out … [Read more…]

Posted in: Angular, Asynchronous, Jasmine, Typescript, Unit Testing Tagged: Angular, Jasmine, Observable, rxjs, Testing, Typescript, unit testing

Jasmine–Async callback was not invoked within timeout

August 10, 2018 by Robert Leave a Comment

Recently I was updating and fixing some existing unit tests after doing a (rather large) overhaul of code.The unit test previously needed to wait for an asynchronous callback to finish before continuing, something like this: Note the optional done parameter provided to beforeEach.  This is a void function that signals Jasmine that the callback is … [Read more…]

Posted in: Angular, Asynchronous, Concurrency, Jasmine, JavaScript, Typescript, Web Development Tagged: async, Asynchronous, beforeEach, Callback, Jasmine, specified, test, Testing, timeout, unit testing

Thread-Safe Atomic Operations

June 29, 2018 by Robert Leave a Comment

There’s been more than a couple times where I’ve wanted to use the Parallel class to take a collection and rip through it with multiple threads, but I’ve struggled with how to log the progress (especially the count of objects processed) easily. Interlocked .NET actually provides the solution in a static class called Interlocked, located … [Read more…]

Posted in: .NET Core, ASP.NET, Asynchronous, C#, Concurrency Tagged: .NET, C#, Concurrency, Thread, Thread Safe, threading

TypeScript async / await

May 4, 2018 by Robert Leave a Comment

JavaScript is pretty dumb.  I know its the most popular language right now (due to the pervasiveness of browsers and other things that can run it), but, I mean, its just… dumb. Luckily TypeScript is pretty awesome.  It takes a lot of what makes JavaScript stupid and fixes it.  It makes it a lot more … [Read more…]

Posted in: Angular, AngularJS, Asynchronous, Concurrency, JavaScript, Typescript, Web Development Tagged: async, await, JavaScript, multi-threaded, promise, single-threaded, threading, threads, Typescript

TimedProcessor – A slightly fancier timer

March 16, 2018 by Robert Leave a Comment

Timers are pretty useful.  They allow you to define a block of code that will execute on a given interval.  It’s the C# version of JavaScript’s setInterval.  There’s a lot of different reasons for using a timer, such as persisting updates to a database.  Since database calls can be slow, maybe you want to build … [Read more…]

Posted in: .NET Core, Asynchronous, C#, Concurrency Tagged: async, Asynchronous, C#, setInterval, Timer

MongoDB–Projecting and filtering out of a list

March 9, 2018 by Robert Leave a Comment

Recently I had an interesting MongoDB query that I wanted to write.  I had a document that contained a list, and I wanted to query a specific item out of the list, returning only the fields that I wanted.  Here’s a similar dataset: In this example, many different records may be created under the same … [Read more…]

Posted in: Asynchronous, C#, Mongo Tagged: C#, CRUD, Lists, Mongo

C# Mongo array CRUD

March 2, 2018 by Robert Leave a Comment

MongoDB is a pretty cool document database that allows you to just toss data into a database without worrying too much about a schema. It’s not quite that easy, of course, because your code might be looking for specific properties, but its simpler than being stuck to a rigid schema. Lists and stuff Recently I … [Read more…]

Posted in: Asynchronous, C#, Mongo Tagged: Array, C#, Create, CRUD, Database, Delete, Mongo, Read, Update

Moq sequential calls

January 26, 2018 by Robert 1 Comment

Say that you’re unit testing and you want a mocked interface to behave differently for different calls to the same method. I was trying to test a TCP listener loop – a TcpListener waits for an incoming connection, does something with it, and then goes back to listening.  In essence, the loop will last until … [Read more…]

Posted in: Asynchronous, C#, Unit Testing Tagged: C#, Concurrency, Moq, unit testing

Unit Testing Angular Observable

December 1, 2017 by Robert 2 Comments

Say that you created a service that essentially wraps Angular’s HttpClient calls: And say that you called that in a component: And now you want to test the Get function to make sure that myValue is set to the value returned by the service.  If you try to create a spy on the function in … [Read more…]

Posted in: Angular, Asynchronous, Jasmine, Unit Testing Tagged: Angular, HttpClient, Jasmine, Observable, Testing, Typescript

ConcurrentHashSet

November 3, 2017 by Robert Leave a Comment

System.Collections.Concurrent provides a bunch of thread-safe collections that you can use when doing asynchronous programming without worrying about bad stuff happening. The simplest ones, ConcurrentBag<T> (which allows you to put stuff in and take things out in an unordered way) and ConcurrentDictionary<TKey, TValue> (a key/value set) are simple and easy to use, but there isn’t … [Read more…]

Posted in: Asynchronous, C#, Concurrency Tagged: Ansychronous, async, C#, Concurrent, ConcurrentBag, ConcurrentDictionary, ConcurrentHashSet, Thread Safe
« Previous 1 2

Recent Posts

  • Allowing trailing JSON commas in ASP.NET Core 3
  • YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
  • Logging in a .NET Core 3 SignalR client
  • .NET Core 3 unit testing project sdk
  • .NET Core 3.0 Upgrade–New JSON Serializer Gotchas

Recent Comments

  1. Robert on C# Setting Socket Keep-Alive
  2. Oliver Schramm on C# Setting Socket Keep-Alive
  3. John Anderson on Waiting for a keypress asynchronously in a C# console app
  4. Ronald Garlit on .NET Core 3 unit testing project sdk
  5. Ronald Garlit on .NET Core 3 unit testing project sdk

Copyright © 2025 Darchuk.NET.

Omega WordPress Theme by ThemeHall