.net-4.0

Disadvantages of using memory mapped files

自古美人都是妖i 提交于 2019-12-06 05:35:39
问题 My web service writes several thousands of transactions per minute and we save them on the hd. I was testing different ways to save these files and I made some tests with standard IO and with MemoryMapped files. In my results, writing files (20 k text files) with MemoryMapped files is about 4x faster than standard IO and I was not able to find any disadvantages. As I have not so much experience with this technology, do you think I may face any problem using them or you don't see any

How to create NAMED-PIPE in .NET-4?

℡╲_俬逩灬. 提交于 2019-12-06 05:23:26
问题 How to create NAMED-PIPE in .NET-4 in your C# application? 回答1: Here is a piece of code to create a Named Pipe client, it is lifted from an answer to a previous question I answered on communicating between C++ and C# using Named Pipes using System; using System.Text; using System.IO; using System.IO.Pipes; namespace CSPipe { class Program { static void Main(string[] args) { NamedPipeClientStream pipe = new NamedPipeClientStream(".", "HyperPipe", PipeDirection.InOut); pipe.Connect(); using

Different behaviour when collection modified between Dictionary and ConcurrentDictionary

☆樱花仙子☆ 提交于 2019-12-06 05:06:32
With a normal Dictionary code as list below, I get exception that Collection was modified; enumeration operation may not execute. Dictionary<int, int> dict2 = new Dictionary<int, int>(); dict2.Add(1, 10); dict2.Add(2, 20); dict2.Add(3, 30); dict2.Add(4, 40); foreach (var d in dict2) { if (dict2.ContainsKey(2)) dict2.Remove(2); if (dict2.ContainsKey(3)) dict2.Remove(3); } However with ConcurrentDictionary, this works fine. ConcurrentDictionary<int, int> dict1 = new ConcurrentDictionary<int, int>(); dict1.AddOrUpdate(1, 10, (k,v)=> 10); dict1.AddOrUpdate(2, 20, (k, v) => 20); dict1.AddOrUpdate(3

TFS 2010 Build Publish via file system

自闭症网瘾萝莉.ら 提交于 2019-12-06 05:04:50
I've got a fairly large MVC2 project in TFS which gets built automatically on checkin (Continuous Integration) At present, the fully built version is dumped on a network share on our dev IIS server. \\Server\wwwrootLatest TFS of course creates lots of sub-folders since it's just doing a build, it isn't even aware that it's drop directory is a wwwroot. This means that to actually USE the build, we need to go and manually create an IIS App which points at the appropriate directory - which defeats the whole object of the exercise. When we do a manual publish to that server, we use "File System"

How to get a trailing slash appended to page routes?

拟墨画扇 提交于 2019-12-06 05:01:00
This is a near identical problem I am having to that of this query, albeit mine is a Web Forms scenario (using routing in .NET 4) as opposed to MVC. Add a trailing slash at the end of each url? The solution that someone mentions there is only half provided unfortunately as the link to the complete solution is broken. At the moment, any trailing slash from my page routes is removed when I get the route url. This is especially problematic when I want to use the following type of inline syntax on my web form: <a runat="server" href='<%$RouteUrl:RouteName=Posts %>'> Again here the trailing slash

Parallel and work division in c#?

为君一笑 提交于 2019-12-06 04:40:55
问题 (let's assume I have 10 cores) When I write: Parallel.For(0, 100, (i,state) => { Console.WriteLine(i); }); Questions: What is the formula of assigning amount of numbers to each core? (is it 100/10 ?) At execution point, does each core already know which numbers is is gonna handle? Or does it consume each time a new number/s from the [0..100] repository (let's ignore chunk or range for now)? The i parameter - does it refer to the 0..100 index or is it a relative index in each thread and its

.NET Framework 4.0 and drawing on Aero Glass issue

*爱你&永不变心* 提交于 2019-12-06 04:37:29
问题 In my application I have a form which I tweak by using the DWM API's method DwmExtendFrameIntoClientArea to extend the height of the Aero Glass Title Bar so that part of my form client area is drawn on the Aero frame. To achieve this effect, I also draw a black rectangle on the part of the client area which is 'over' the glass frame so that it appears transparent, as many online articles suggest. This worked pretty well under Windows Vista/Windows 7 but as I downloaded VS 2010 and used the

LogonUserIdentity.Name vs. User.Identity.Name

别等时光非礼了梦想. 提交于 2019-12-06 04:18:42
问题 I have an ASP.NET Web Forms Application project that is running upon the 4.0 framework. I'm very familiar with Web Applications, but not so much with Web Forms Applications. I ran into a notable difference between the two of them today, and I'm confused at why this difference even exists. Typically, in a Web Application, if I want to determine who the current user of the page is then I just retrieve their domain log-in from User.Identity.Name . So, I was quite perplexed when I hit F5 to run

Defending against race conditions in System.Collections.Concurrent.ConcurrentDictionary

ぐ巨炮叔叔 提交于 2019-12-06 04:07:36
问题 The .NET ConcurrentDictionary is susceptible to a race condition that may cause unexpected data as explained at the bottom of this MSDN article. I'm assuming that there are several factors to take into account. Q: How should I write code that is not vulnerable to that race condition that may cause data loss? In my scenario I have an input stream that has an always increasing index (n++). My thought is that I could detect missing data if the race condition occurs and re-send it. On the other

Problems with IMetaDataImport::ResolveTypeRef Method

∥☆過路亽.° 提交于 2019-12-06 04:05:46
问题 I have my own debugger for .NET apps that uses IMetaDataImport interface When I call ResolveTypeRef method, I always get NotImplementedException . The definition of ResolveTypeRef is like this: [ComImport] [Guid("....")] //a valid GUID [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [CLSCompliant(false)] public interface IMetaDataImport { void ResolveTypeRef( [ComAliasName("mdTypeRef")] mdToken tr, [ComAliasName("REFIID")] ref Guid riid, [ComAliasName("IUnknown**"), Out, MarshalAs