.net-4.0

Implement IDownloadManger for my application only

拟墨画扇 提交于 2019-12-21 02:21:11
问题 I'm using the WebBrowser control in a WinForms application and have implemented my own download manager by following the instructions here. My custom download manager works, but also overrides the download manager for Internet Explorer , too*. Is there a way to only have the custom download manager appear when my application is running? Or is there a way to unregistered it when my application closes? *I appreciate that is precisely the point of implementing IDownloadManager , and the

TransactionScope alternative without DTC

一个人想着一个人 提交于 2019-12-21 01:19:47
问题 are there any alternative to transactionScope which does not need to enable DTC?? In the transaction I need to make two operations: Create one user (using membership - sql membership provider) Do one insert operation. 回答1: TransactionScope uses the LTM - Lightweight Transaction Manager in .Net. Only if you open more than one connection in the same transaction or go between databases, should TransactionScope promote the transaction to the 2PC-based TX-manager, DTC. For MS SQL Server 2008 and

C# queueing dependant tasks to be processed by a thread pool

一曲冷凌霜 提交于 2019-12-21 01:13:22
问题 I want to queue dependant tasks across several flows that need to be processed in order (in each flow). The flows can be processed in parallel. To be specific, let's say I need two queues and I want the tasks in each queue to be processed in order. Here is sample pseudocode to illustrate the desired behavior: Queue1_WorkItem wi1a=...; enqueue wi1a; ... time passes ... Queue1_WorkItem wi1b=...; enqueue wi1b; // This must be processed after processing of item wi1a is complete ... time passes ..

.NET 4 equivalent of Task.WhenAll()

做~自己de王妃 提交于 2019-12-20 17:41:14
问题 In .NET 4, is there any functional equivalent to .NET 4.5's System.Threading.Tasks.Task.WhenAll()? The goal is to wrap up multiple async tasks into a single one that is completed when all of its constituent tasks are done. 回答1: I think the closest thing built-in in .Net 4.0 is ContinueWhenAll(). You can make the continuationAction a simple tasks => tasks and use the returned Task . For performance reasons, you might want to use it with TaskContinuationOptions.ExecuteSynchronously . 回答2: In

.NET 4 equivalent of Task.WhenAll()

我们两清 提交于 2019-12-20 17:40:06
问题 In .NET 4, is there any functional equivalent to .NET 4.5's System.Threading.Tasks.Task.WhenAll()? The goal is to wrap up multiple async tasks into a single one that is completed when all of its constituent tasks are done. 回答1: I think the closest thing built-in in .Net 4.0 is ContinueWhenAll(). You can make the continuationAction a simple tasks => tasks and use the returned Task . For performance reasons, you might want to use it with TaskContinuationOptions.ExecuteSynchronously . 回答2: In

Garbage collection in .Net 4.0

北城以北 提交于 2019-12-20 17:30:19
问题 Is there any change in .Net 4.0 garbage collector execution? 回答1: Here's a blog posting: http://geekswithblogs.net/sdorman/archive/2008/11/07/clr-4.0-garbage-collection-changes.aspx and http://www.infoq.com/news/2009/06/Background-Collector 回答2: There is also AppDomainResourceManager feature, which allows you to track resource usage ( Memory and CPU ) per appdomain. the GC part of this feature is the ability to get per appdomain memory tracking. 回答3: There's also an ephemeron implemenation

C# code very slow with debugger attached; MemoryMappedFile's fault?

爷,独闯天下 提交于 2019-12-20 12:38:35
问题 I have a client/server app. The server component runs, uses WCF in a 'remoting' fashion (binary formatter, session objects). If I start the server component and launch the client, the first task the server does completes in <0.5sec. If I start the server component with VS debugger attached, and then launch the client, the task takes upwards of 20sec to complete. There are no code changes - no conditional compilation changes. The same occurs whether I have the server component compiled and

Web api performance?

此生再无相见时 提交于 2019-12-20 12:35:17
问题 I was thinking , The WebApi along with routing mechanism works in such way that it reads the http verb ( GET POST etc...) and then searches for matched method names / parameters : For example : If it's GET and the URI is api/Customers/5 : method should start with Get if it has ID so search a method which accepts int as parameter. etc. (there are more rules). I mostly believe they did it using reflection. Question : Isn't it a performance hit , for every URI request - to search all this data

Custom Delegating Handler specific to a Controller in ASP.NET Web API

廉价感情. 提交于 2019-12-20 12:10:20
问题 I have written a Custom Delegating Handler which add custom headers to the response & checks in the request . I added the handles in WebAPi configuration config.MessageHandlers.Add(new customHandler()); But the issue is applies to all the controllers. I need to apply custom header specific to a controllers. Is it possible to add custom handlers specific to a controller? 回答1: At the end of this article it explains how to apply handlers only to certain routes: http://www.asp.net/web-api

Why is lambda faster than IL injected dynamic method?

心已入冬 提交于 2019-12-20 11:49:38
问题 I just built dynamic method - see below (thanks to the fellow SO users). It appears that the Func created as a dynamic method with IL injection 2x slower than the lambda. Anyone knows why exactly? (EDIT : this was built as Release x64 in VS2010. Please run it from console not from inside Visual Studio F5.) class Program { static void Main(string[] args) { var mul1 = IL_EmbedConst(5); var res = mul1(4); Console.WriteLine(res); var mul2 = EmbedConstFunc(5); res = mul2(4); Console.WriteLine(res)