.net-4.0

NHibernate 1.2 in a .NET 4.0 solution

余生颓废 提交于 2019-12-31 13:16:08
问题 I have some projects based on NHibernate 1.2 and I'd like to add them to a .NET 4.0 solution, but I get an AmbiguousMatchException. No matter if these projects are targeted to 2.0 or 4.0 framework. It works if I add them to a .NET 3.5 solution. Does anyone have experience with that? Here is the exception: [AmbiguousMatchException: Ambiguous match found.] System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types,

Is it OK to try to use Plinq in all Linq queries?

夙愿已清 提交于 2019-12-31 12:40:12
问题 I read that PLinq will automatically use non parallel Linq if it finds PLinq to be more expensive. So I figured then why not use PLinq for everything (when possible) and let the runtime decide which one to use. The apps will be deployed to multicore servers and I am OK to develop a little more code to deal with parallelism. What are the pitfalls of using plinq as a default? 回答1: One pit fall is you lose the ability to leverage ordering in sets. Take the following code: var results = new int {

Is it OK to try to use Plinq in all Linq queries?

本秂侑毒 提交于 2019-12-31 12:40:02
问题 I read that PLinq will automatically use non parallel Linq if it finds PLinq to be more expensive. So I figured then why not use PLinq for everything (when possible) and let the runtime decide which one to use. The apps will be deployed to multicore servers and I am OK to develop a little more code to deal with parallelism. What are the pitfalls of using plinq as a default? 回答1: One pit fall is you lose the ability to leverage ordering in sets. Take the following code: var results = new int {

Possible multiple enumeration of IEnumerable? [duplicate]

♀尐吖头ヾ 提交于 2019-12-31 10:40:14
问题 This question already has answers here : Handling warning for possible multiple enumeration of IEnumerable (7 answers) Closed 5 years ago . why is that ? how can I fix it ? 回答1: There is nothing to fix here. Any() will iterate the enumeration but stop after the first element (after which it returns true). Multiple enumerations are mainly a problem in two cases: Performance: Generally you want to avoid multiple iterations if you can, because it is slower. This does not apply here since Any()

Delay property on Binding from .Net 4.5 in .Net 4.0

纵然是瞬间 提交于 2019-12-31 09:05:22
问题 How can I implement Delay property from .Net 4.5 (described here) on binding in .Net 4.0? I know I cannot inherit from BindingBase as ProvideValue is sealed. I could implement MarkupExtension but it means I now have to rewrite all properties from BindingExtension is there any other way? 回答1: I would create an AttachedProperty that specifies the amount of time to Delay. The AttachedProperty would start (or reset) a timer when the bound value changes, and would manually update the bound source

Delay property on Binding from .Net 4.5 in .Net 4.0

此生再无相见时 提交于 2019-12-31 09:05:11
问题 How can I implement Delay property from .Net 4.5 (described here) on binding in .Net 4.0? I know I cannot inherit from BindingBase as ProvideValue is sealed. I could implement MarkupExtension but it means I now have to rewrite all properties from BindingExtension is there any other way? 回答1: I would create an AttachedProperty that specifies the amount of time to Delay. The AttachedProperty would start (or reset) a timer when the bound value changes, and would manually update the bound source

C# “Local” variable loaded inside a task won't keep its value when called outside the task

我是研究僧i 提交于 2019-12-31 07:32:12
问题 I'm running in circles with this one. I have some tasks on an HttpClient (.NET 4 with httpclient package from NuGet), in one of them i'm trying to assign a value to a variable that i declared OUTSIDE the task, at the beggining of the function, but when the execution gets to that point, the variable lost the assigned value and came back to the initial value, like it never changed. But I'm pretty sure it DID change at a moment, when the execution passed through the task. I've made this

C# “Local” variable loaded inside a task won't keep its value when called outside the task

核能气质少年 提交于 2019-12-31 07:31:05
问题 I'm running in circles with this one. I have some tasks on an HttpClient (.NET 4 with httpclient package from NuGet), in one of them i'm trying to assign a value to a variable that i declared OUTSIDE the task, at the beggining of the function, but when the execution gets to that point, the variable lost the assigned value and came back to the initial value, like it never changed. But I'm pretty sure it DID change at a moment, when the execution passed through the task. I've made this

How to call an appropriate method by string value from collection?

自作多情 提交于 2019-12-31 06:25:14
问题 I have a collection of strings. For example, string[] coll={"1", "2", "3" ..."100"..."150"...} and I have respective methods for the string collection such as void Method1, void Method2, void Method100 I select appropriate method like that: string selector=string.Empty; switch(selector) { case "1": MethodOne(); break; ........ case "150": Method150(); break; } The above code is really bored and I will have more string elements in the string collection {"150" ... "250"...}. How to make like

How can I get the UI thread to wait on a semaphore, but process additional dispatcher requests? (like what MessageBox.Show does natively)

天大地大妈咪最大 提交于 2019-12-31 05:42:12
问题 Normally, when the UI thread calls something like MessageBox.Show() , the current code execution doesn't continue until the user clicks OK, but the program will continue to run other code dispatched on the UI thread. In this question, I had a problem with too many delegates dispatched on the UI Thread being called at once. I wanted to pause at certain points before continuing execution. In my new Error handler, I use semaphores to make sure no more than one error is being handled at once. I