MSBuild timestamp issue with incremental build

I have a C# class library project that references another class library project (EdmResources references Framework). EdmResources only contains a T4 template which is always executed when the project builds, to compile and write out EDMX files for Entity Framework. The EdmResources project always builds, regardless of whether the Framework assembly is up-to-date or needed to be built as well -

具有增量构建的MSBuild时间戳问题

我有一个C#类库项目引用另一个类库项目(EdmResources参考框架)。 EdmResources只包含一个T4模板,该模板在构建项目时总是执行,为实体框架编译和写出EDMX文件。 无论Framework程序集是最新的还是需要构建的,EdmResources项目都会构建,这会大大减慢我们的构建过程。 我想要的是EdmResources只在框架程序集需要重新编译时才会生成。 我试着输出框架程序集的最后一次写入时间作为EdmResources.tt的输出,然后如果程序集

Deserializing Json in Console App

I am creating a Web API endpoint that will act as a service to retrieve our application configurations, do logging, etc. The problem I am running into is being able to deserialize the Json in the console applications. Setup public class Person { public string FirstName { get; set; } public string LastName { get; set; } public DateTime DateOfBirth { get; set; } } Web API [HttpGet]

在控制台应用程序中反序列化Json

我正在创建一个Web API端点,它将充当服务来检索我们的应用程序配置,执行日志记录等。我遇到的问题是能够在控制台应用程序中反序列化Json。 建立 public class Person { public string FirstName { get; set; } public string LastName { get; set; } public DateTime DateOfBirth { get; set; } } Web API [HttpGet] [Route("Person")] public IHttpActionResult GetPerson() { Person person = new Perso

does it always release the lock?

I have recently read this post from Eric Lippert regarding the lock implementation in c# and still some questions remain. In 4.0 implementation if a thread abort or any cross thread exception occurs just before the Monitor.Exit(temp) in the finally block is executed - would that keep the lock on the object? Is there any possibility for an exception to occur at this level, leaving the object s

它总是释放锁吗?

我最近从Eric Lippert那里读到关于c#中锁定实现的这篇文章,但仍然存在一些问题。 在4.0实现中,如果在执行finally块中的Monitor.Exit(temp)之前发生线程中止或任何交叉线程异常 - 是否将锁定在对象上? 是否有可能在此级别发生异常,使对象仍处于锁定状态? 在4.0实现中,如果在执行finally块中的Monitor.Exit(temp)之前发生线程中止或任何交叉线程异常 - 是否将锁定在对象上? 让我们来看看这些代码,以便其他读者

Lock (Monitor) internal implementation in .NET

For mastering of some technology you have to know how it's made at one abstraction level lower. In case of multithreading programming, it will be good to know about synchronization primitives. Here is the question, how implemented Lock (Monitor) in .NET? I'm intrested in such points: - does it utilize OS objects?; - does it require user mode or kernel mode?; - what is overhead

在.NET中锁定(监视器)内部实现

掌握一些技术,你必须知道它是如何在一个抽象层次上降低的。 在多线程编程的情况下,最好了解同步原语。 这里是一个问题,如何在.NET中实现Lock(Monitor)? 我对这样的观点很感兴趣: - 它是否利用OS对象? - 它需要用户模式还是内核模式? - 等待锁定的线程的开销是多少? - 在什么情况下可能会违反等待锁的线程队列? 更新: “如果多个线程竞争锁定,它们将排队在”就绪队列“上,并以先到先得的方式授予

Overriding C#'s Monitor.Enter and Monitor.Exit

I'm working on some big multi threaded project, now yesterday I had a deadlock (my first one ever), and I traced it by adding a Console.WriteLine("FunctionName: Lock on VariableName") and Console.WriteLine("FunctionName: Unlocking VariableName"). Adding all those was quite some work. First of all, the program has a main loop that runs 2 times per second, that loop pulse

重写C#的Monitor.Enter和Monitor.Exit

我正在研究一些大的多线程项目,现在我昨天遇到了一个死锁(我的第一个死锁),并通过添加Console.WriteLine(“FunctionName:Lock on VariableName”)和Console.WriteLine(“FunctionName :解锁VariableName“)。 添加所有这些都是一些工作。 首先,该程序有一个每秒运行2次的主循环,该循环会在主循环处理完毕后触发一些其他线程完成其工作。 现在发生的事情是,我有一个处于等待状态的线程被脉冲化,当它被脉冲称为另一

Rx.Net Message Parser

I'm trying to parse an incoming stream of bytes that represents messages. I need to split the stream and create a message structure for each part. A message always starts with a 0x81 (BOM) and ends with a 0x82 (EOM). start: 0x81 header: 3 bytes data: arbitrary length stop: 0x82 The data part is escaped using an escape byte 0x1B (ESC): Anytime a byte in the data part contains one of

Rx.Net消息解析器

我试图解析表示消息的传入字节流。 我需要拆分流并为每个部分创建一个消息结构。 消息总是以0x81(BOM)开始,以0x82(EOM)结束。 start: 0x81 header: 3 bytes data: arbitrary length stop: 0x82 数据部分使用转义字节0x1B(ESC)进行转义:任何时候,数据部分中的某个字节都包含控制字节{ESC,BOM,EOM}中的一个,它以ESC作为前缀。 标题部分不会被转义,并且可能包含控制字节。 我想通过使用Rx.Net以功能反应

.Net Memory Leak when creating lots of threads

I have an application that creates lot of threads over time. I noticed that memory usage grows as it runs and eventually runs out of memory. But the same code doesn't leak memory on my coworker's environment. We both have same .net version. I was able to reproduce the issue with the following sample code which doesn't leak on my coworker's laptop but does on my laptop. public

在创建大量线程时.Net内存泄漏

我有一个应用程序随着时间的推移创建了大量的线程。 我注意到内存使用量随着运行而增长,并最终耗尽内存。 但是相同的代码不会泄漏我的同事环境中的内存。 我们都有相同的.net版本。 我能够用下面的示例代码重现问题,该代码不会在我的同事的笔记本电脑上泄漏,但会在我的笔记本电脑上泄漏。 public static void Main(string[] args) { Console.WriteLine("Version " + Environment.Version.ToString());

Volatile vs. Interlocked vs. lock

Let's say that a class has a public int counter field that is accessed by multiple threads. This int is only incremented or decremented. To increment this field, which approach should be used, and why? lock(this.locker) this.counter++; , Interlocked.Increment(ref this.counter); , Change the access modifier of counter to public volatile . Now that I've discovered volatile , I

易失与互锁与锁定

假设一个类有一个public int counter字段,可以被多个线程访问。 这个int只是递增或递减。 为了增加这个领域,应该使用哪种方法,为什么? lock(this.locker) this.counter++; , Interlocked.Increment(ref this.counter); , 将counter的访问修饰符更改为public volatile 。 现在我发现了volatile ,我一直在删除很多lock语句和Interlocked的使用。 但是有没有理由不这样做? 最差(实际上不会工作) 将counte

multimap in .NET

I need an equivalent to c++'s std::multimap<K, V, Comp, Alloc> in C-sharp. Does it exist in the standard library? 因为它几乎是圣诞节:) ////////////////////////////////////////////////////////////////////// // Algorithmia is (c) 2008 Solutions Design. All rights reserved. // http://www.sd.nl ////////////////////////////////////////////////////////////////////// // COPYRIGHTS: // Copyri

.NET中的multimap

我需要在C-sharp中与c ++的std::multimap<K, V, Comp, Alloc>等效。 它存在于标准库中吗? 因为它几乎是圣诞节:) ////////////////////////////////////////////////////////////////////// // Algorithmia is (c) 2008 Solutions Design. All rights reserved. // http://www.sd.nl ////////////////////////////////////////////////////////////////////// // COPYRIGHTS: // Copyright (c) 2008 Solutions Design. Al

intermittent error with webservice client

We are seeing an intermittent issue on some of our production servers. By intermittent I mean this is currently affecting less than 1% of our total jobs running, and only shows up in 2 of our ~20 servers (where we've noticed this at least). Our setup is this: We have a custom piece of software which is a bastardized version of old VB6 and C#.net code. The program is a webscraping engine f

与web服务客户端间歇性错误

我们在部分生产服务器上看到间歇性问题。 间歇性地说,我的意思是,目前影响到我们总运行量的不到1%,并且只在我们的〜20台服务器中有两台显示(我们至少注意到了这一点)。 我们的设置是这样的:我们有一个自定义的软件,它是旧的VB6和C#.net代码的混合版本。 该计划是我们自己内部脚本的网页扫描引擎。 该程序通过服务器园区执行,每个服务器一次运行50-150个实例,每个实例都有一个单独的脚本。 会发生什么是在初始