.net-4.0

UnsafeQueueUserWorkItem and what exactly does “does not propagate the calling stack” mean?

筅森魡賤 提交于 2019-12-06 18:39:34
问题 I am reading and learning about ThreadScheduler and articles around Tasks and came across the function ThreadPool.UnsafeQueueUserWorkItem used in one of the MSDN examples about own ThreadSchedulers. In the MSDN description about UnsafeQueueUserWorkItem there is a big warning that the function may be an security hole and that it " does not propagate the calling stack ". The only link is to QueueUserWorkItem which - from the name - seems to be the "safe counterpart"? but does not mention

Thread.CurrentPrincipal in .NET console application

拜拜、爱过 提交于 2019-12-06 18:06:41
问题 Here is a trivial console application that i run in command prompt: using System; using System.Threading; namespace Test { internal class Runner { [STAThread] static void Main(string[] args) { Console.WriteLine(Thread.CurrentPrincipal.GetType().Name); Console.WriteLine(Thread.CurrentPrincipal.Identity.Name); } } } The output is 'GenericPrincipal' and empty string as identity name. Why the run-time constructs GenericPrincipal instead of WindowsPrincipal ? How do i force it to construct

Changing Socket Options on WCF net.tcp binding

瘦欲@ 提交于 2019-12-06 17:43:02
问题 I have a .net 4.0 WCF application that uses the net.tcp binding and implements some service. I would like to set a TCP socket option for that binding ( ReuseAddress option. A related question explains why I want to do that). If I was working with Raw Sockets I could use the Socket.SetSocketOption Method. Is there a way to somehow extract the underlying Raw Socket from the net.tcp binding in order to change its options? Or some other way to set this option? 回答1: Amir, Thank you for your

Using ReadAsAsync<T>() to deserialize complex Json object

假如想象 提交于 2019-12-06 17:38:43
问题 I want to use ReadAsAsync() in my mvc project with .net 4.0. The result comes as null. If I enter the uri to address bar, the result in chrome as(tag names are changed): <ns2:MyListResponse xmlns:ns2="blablabla"> <customerSessionId>xxcustomerSessionIdxx</customerSessionId> <numberOfRecordsRequested>0</numberOfRecordsRequested> <moreResultsAvailable>false</moreResultsAvailable> <MyList size="1" activePropertyCount="1"> <MySummary order="0"> <id>1234</id> <name>...</name> . . </MySummary> <

Cast List of Anonymous type to List of Dynamic Objects

坚强是说给别人听的谎言 提交于 2019-12-06 17:25:23
问题 Why can't I cast a List<AnonymousObject> to a List<dynamic> ? I have this following code: var datasource = someList.Select(o => new { x = o.A, y = o.B }); dgvSomeGridView.DataSource = datasource.ToList(); dgvSomeGridView.DataBind(); Then I access the GridView.DataSource with the following code: var ds = ((List<dynamic>)dgvSomeGridView.DataSource); .... But it throws an error on the line where I cast it to List<dynamic> , it says: Unable to cast object of type System.Collections.Generic.List'1

Confirmed features of .NET 4.0? [closed]

好久不见. 提交于 2019-12-06 15:54:22
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . Does anyone know what will be in .NET 4.0? I found tuples on codeplex: .... // NOTE : this is a TEMPORARY and a very minimalistic implementation of Tuple

WPF Inner Glow Effect

為{幸葍}努か 提交于 2019-12-06 15:29:05
Does anyone know how to make an Inner Glow effect in WPF without using expression blend or deprecated BitmapEffects? Sample image: For instance, here is some xaml for a button with an image and some text. I want this button to have an inner glow (not an outer glow): <Button Click="HandleDeleteRows" Style="{StaticResource ButtonCellStyle}"> <DockPanel> <Image Style="{StaticResource DeleteButtonImage}" /> <TextBlock Style="{StaticResource DeleteButtonCaption}" /> </DockPanel> </Button> While my simplified example above is solved by PompolutZ's answer, I wasn't in a position to override the

IronPython import performance with compiled code

百般思念 提交于 2019-12-06 15:02:21
I am doing some experiments with IronPython 2.6.1 and the clr.CompileModules function to compile my large scripts into assemblies. Testing has shown good cold start performance performance improvements but in some cases importing the compiled module is actually slower than executing a large string that represents my code in some cases. My question is, if i use something like scope.Engine.Execute(string.Format("from {0} import {0}", theModule), scope); or the ImportModule function, even though I get a new ScriptSCope back does the DLR cache the imports made in other ScriptScopes? So if module 1

Converting IEnumerable<T> to List<T> on a LINQ result, huge performance loss

北战南征 提交于 2019-12-06 14:58:48
On a LINQ-result you like this: var result = from x in Items select x; List<T> list = result.ToList<T>(); However, the ToList<T> is Really Slow, does it make the list mutable and therefore the conversion is slow? In most cases I can manage to just have my IEnumerable or as Paralell.DistinctQuery but now I want to bind the items to a DataGridView, so therefore I need to as something else than IEnumerable , suggestions on how I will gain performance on ToList or any replacement? On 10 million records in the IEnumerable , the .ToList<T> takes about 6 seconds. .ToList() is slow in comparison to

ASP.NET 4 changes with automatic names of controls

徘徊边缘 提交于 2019-12-06 14:57:17
I just updated an app from .NET 2.0 to .NET 4.0 and I have noticed the following. For example I have the following control: <input type="hidden" name="ctl00$cphMain$hfdFueraHorarioOficinaConfirmado" id="cphMain_hfdFueraHorarioOficinaConfirmado" value="False" /> and then in javascript I did this before: var hfdFueraHorarioOficinaConfirmado=document.getElementById('ctl00_cphMain_hfdFueraHorarioOficinaConfirmado'); but after checking the id within the html source once it renders and also doing some debugging with firebug etc it has changed from: ctl00_cphMain_hfdFueraHorarioOficinaConfirmado to: