.net-4.0

How do I trigger or supress the display of Windows Virtual Keyboard

人走茶凉 提交于 2019-12-05 06:15:12
问题 In WPF I have a screen for login which has a textbox for username and a password box for password. I ideally need to prevent the on-screen keyboard from displaying so I can use a custom keyboard in the perfect location in the app. Failing that I need to somehow force the on-screen keyboard to display for the password box. I've found the Microsoft.Ink.TextInput.TextInputPanel seems to have most of this functionality in .net 3.5, but I can't find an equivalent in .net 4.0 P.S. Any textboxes on

Error CS0433 in large precompiled Asp.net Website Project

醉酒当歌 提交于 2019-12-05 05:33:43
Background I've taken over a very large asp.net website project. The old deploy process was to copy .cs, .aspx, and .ascx files to IIS and have it build on the fly. I want to precompile it and use TeamCity to automatically deploy it. I've done this with some of the other website projects. The project has about 350 user controls that are nicely organized in folders but are used all over the place. Controls referenced from other folders, from each other... Basically a circular file reference nightmare. My Attempt My first attempt was to build it like the others. MSbuild the whole vs2012 solution

How to check that all tasks have been properly completed?

别说谁变了你拦得住时间么 提交于 2019-12-05 05:18:13
I have the following lines in my code: var taskA = Task.Factory.StartNew(WorkA); var taskB = Task.Factory.StartNew(WorkB); var allTasks = new[] { taskA, taskB }; Task.Factory.ContinueWhenAll(allTasks, tasks => FinalWork(), TaskContinuationOptions.OnlyOnRanToCompletion); But when I run this, I get the following error: It is invalid to exclude specific continuation kinds for continuations off of multiple tasks. Which is caused by the option TaskContinuationOptions.OnlyOnRanToCompletion . My question is how to check that all tasks have done their work properly (all tasks statuses are

Action/Lambda Expression Memory Management Question

点点圈 提交于 2019-12-05 05:12:36
I'm storing an action in a local variable, then I'm using after that local variable is out of scope. Is it in danger of being cleaned up before I use it? Here is an example: public List<object> GetMaps() { Action<Customer1, Customer2> baseMap = (Customer1 c1, Customer2 c2) => { c2.FirstName = c1.FirstName; }; var list = new List<object>() { new Action<SpecialCustomer1 c1, SpecialCustomer2 c2>() { baseMap(c1, c2); c2.SpecialProperty = c1.SpecialProperty; }, new Action<SpecialCustomer1 c1, SpecialCustomer2 c2>() { baseMap(c1, c2); c2.SpecialProperty2 = c1.SpecialProperty2; }, }; return list; }

Powershell 2.0 Remoting loading a .Net 4.0 dll

非 Y 不嫁゛ 提交于 2019-12-05 04:54:10
I am trying to load a .Net 4.0 assembly, using [Reflection.Assembly]::LoadFrom, inside of a remote Powershell 2.0 session. It works locally, due to a change I made to the powershell.exe.config file, but fails with a "This assembly is built by a runtime newer ..." exception in a remote session. Both machines involved have .Net 2.0 and 4.0, and have the powershell.exe.config change for the x86 and x64 bit powershell executables. I've also tried changing the server powershell registry keys: HKLM:\Software\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion HKLM:\Software\Wow6432Node\Microsoft

Is BackgroundWorker's IsBusy same as “IsAlive”?

谁都会走 提交于 2019-12-05 04:51:55
I am trying to figure out a way to verify that a BackgroundWorker thread is alive (i.e. still running. The thread is essentially implemented as a simple infinite loop: while (AllConditionsMet()) { DoSomeMagic(); Thread.Sleep(10000); } The closest thing to IsAlive() I found so far is the IsBusy property, but given that my thread Sleep()s most of the time, I am not sure whether this will do the job. Can I count on IsBusy to do: if (!myWorker.IsBusy) RestartWorker(); or am I calling for trouble? Hans Passant BackgroundWorker.IsBusy is true as long as the DoWork event handler is busy and the

Which way is preferred when doing asynchronous WCF calls?

落花浮王杯 提交于 2019-12-05 04:18:26
When invoking a WCF service asynchronous there seems to be two ways it can be done. 1. WcfClient _client = new WcfClient(); public void One() { _client.BegindoSearch("input", ResultOne, null); } private void ResultOne(IAsyncResult ar) { string data = _client.EnddoSearch(ar); } 2. public void Two() { WcfClient client = new WcfClient(); client.doSearchCompleted += TwoCompleted; client.doSearchAsync("input"); } void TwoCompleted(object sender, doSearchCompletedEventArgs e) { string data = e.Result; } And with the new Task<T> class we have an easy third way by wrapping the synchronous operation in

Comparer<T>.Create in .NET 4

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 04:18:16
问题 I have created a Comparer in .Net 4.5: public static Comparer<Room> RoomComparer = Comparer<Room>.Create((a, b) => a.RoomId.CompareTo(b.RoomId)) How can i create Comparer in c# .NET 4.0? 回答1: You can use the following public static class Comparer { public static Comparer<T> Create<T>(Comparison<T> comparison) { if (comparison == null) throw new ArgumentNullException("comparison"); return new ComparisonComparer<T>(comparison); } private sealed class ComparisonComparer<T> : Comparer<T> {

Force Task<T> to different core ?

时间秒杀一切 提交于 2019-12-05 03:57:24
问题 Tpl and Plinq automatically assign work to threads (at core/s... { well ,if #threads> #cores then , >1 thread will run on the same core. }). However , Let's say I have MyMethod1(){..} and MyMethod2(){..} and I need to make sure (!) that each will run on a different core! (e.g. intensive computing) The nearest solution I found is Plinq's .WithExecutionMode (ParallelExecutionMode.ForceParallelism) But this is for a different situation where Plinq might think that it is better to do it

What is C# equivalent of geography sql server datatype in .net framework 4.0?

喜你入骨 提交于 2019-12-05 03:57:13
net web application using .net 4.0 framework. I have a Stored Procedure which accepts geography datatype in sql server 2008 R2. I want to insert data from C# code into SQL Server. But I'm not able to find which datatype I should use in C# that is equivalent to SQL Server 2008 datatype. If you are using entity-framework then the datatype you search is DbGeography. Here is some more information about DbGeography object -> Details . It may sound obvious, but why not use the same data type that has been installed as a UDT in SQL Server - SqlGeography ? The following works fine against a SQL Server