Why do I get the following error? Invalid variance modifier. Only interface and delegate type parameters can be specified as variant

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Variance { class A { } class B : A { } class C<out T> { } class Program { static void Main(string[] args) { var v = new C<B>(); CA(v); } static void CA(C<A> v) { } } } Answer This is the offending line: … Read more

How to execute a windows batch command recursively?

For example, you have a rename command in a batch file, and you want to execute that file on the current directory and all sub-directories. Answer Suppose your batch is named something like myrename.cmd, then you can easily do the following: call myrename.cmd for /r /d %%x in (*) do ( pushd “%%x” call myrename.cmd … Read more

gdb: set a breakpoint for a SIGBUS handler

I’m trying to debug a simple stop-and-copy garbage collector (written in C) using GDB. The GC works by handling SIGBUS. I’ve set a breakpoint at the top of my SIGBUS signal handler. I’ve told GDB to pass SIGBUS to my program. However, it doesn’t appear to work. The following program (explained inline) shows the essence … Read more

Convert.ToDouble(“4089.90”) outputs 40.899,00 why?

I am developing a software that uses number precision, but I have this problem, it happens that when I take a string to convert to double it outputs me with a different culture. For example I use Convert.ToDouble(“4089.90”); // it outputs 40.899,00 Is strange cause in my computer it works OK but on the client’s … Read more

what is the best way to synchronize container access between multiple threads in real-time application

I have std::list<Info> infoList in my application that is shared between two threads. These 2 threads are accessing this list as follows: Thread 1: uses push_back(), pop_front() or clear() on the list (Depending on the situation) Thread 2: uses an iterator to iterate through the items in the list and do some actions. Thread 2 … Read more

Name of the thread in the ThreadPool – C#

I am using ThreadPool to execute a set of tasks in a windows service. The service spawns new threads every 10seconds. I would like to record the name of the thread that picked up a particular task from the database. Is it possible to get the name of the thread? Answer The easiest way for … Read more