草庐IT

dispatch_time_t

全部标签

c# - Dispatcher.Invoke with anonymous delegate 在 Silverlight 中有效但在 WPF 中无效

在Silverlight4中,我有一个自定义服务类,它有一个异步的Completed事件。在Completed事件中,我获取返回的数据并通过如下方式调用填充方法:privatevoidservice_Completed(objectsender,CompletedEventArgsargs){Dispatcher.BeginInvoke(()=>populateInbox(args.Jobs));}privatevoidpopulateInbox(Listjobs){inbox.DataContext=jobs;}BeginInvoke在SL4中工作,但是当我将它移植到WPF时,出现以

c# - 为什么 Visual Studio IDE 有时会初始化“this.components 对象 : and other times not?

我最近注意到VisualStudioDesigner(C#)的一些我不理解的行为,想知道是否有人可以澄清...在我的一些Windows窗体中,设计器生成的代码的第一行是这样的;this.components=newSystem.ComponentModel.Container();在这种情况下,dispose方法在同一个设计器文件中,dispose方法在case“if”条件下放置两个“Dispose”调用,如下所示;protectedoverridevoidDispose(booldisposing){if(disposing&&(components!=null)){componen

c# - 为什么每个 Dispatcher.BeginInvoke 回调都有一个唯一的同步上下文?

我刚刚注意到,在.NET4.5中,每个Dispatcher.BeginInvoke/InvokeAsync回调都在其自己非常独特的同步上下文(的实例)上执行DispatcherSynchronizationContext).这种变化背后的原因是什么?以下简单的WPF应用说明了这一点:usingSystem;usingSystem.Diagnostics;usingSystem.Threading;usingSystem.Windows;usingSystem.Windows.Threading;namespaceWpfApplication{publicpartialclassMain

c# - Dispatcher.BeginInvoke 问题

对于此代码,我收到“非静态字段、方法或属性‘System.Windows.Threading.Dispatcher.BeginInvoke(System.Action)’需要对象引用”。privatevoidResponseCompleted(IAsyncResultresult){HttpWebRequestrequest=result.AsyncStateasHttpWebRequest;HttpWebResponseresponse=request.EndGetResponse(result)asHttpWebResponse;using(StreamReadersr=newSt

c# - System.Net.Mail.SmtpException : The operation has timed out. 错误在asp.net发送邮件代码使用godaddy托管

我正在使用以下代码和平使用godaddy托管发送邮件。但它抛出System.Net.Mail.SmtpException:Theoperationhastimedout.protectedvoidsendmail(){varfromAddress="frommailid@site.com";//anyaddresswheretheemailwillbesendingvartoAddress="to@gmail.com";//PasswordofyourgmailaddressconststringfromPassword="mypassword";//Passingthevaluesa

c# - WPF Dispatcher BeginInvoke 排序保证

如果我打电话Dispatcher.BeginInvoke(operation,DispatcherPriority.Loaded)来自20多个线程的1,000,000次,这1,000,000次操作是否保证按BeginInvoke调用的顺序由UI线程执行? 最佳答案 msdn说IfmultipleBeginInvokecallsaremadeatthesameDispatcherPriority,theywillbeexecutedintheorderthecallsweremade但是如果您从多个线程访问Dispatcher那么An

c# - IdentityServer4/Newtonsoft.Json 中的探查器 BLOCKED_TIME

我遇到的问题是我的IdentityServer的/connect/introspect端点有时真的很慢(一次调用需要10秒)。正如您在下面看到的,大多数调用(18k)执行得很快(我启用了新的ApplicationInsightsprofiling大多数缓慢的轨迹看起来像这样:正如在ApplicationInsightsprofilerpage上所说:BLOCKED_TIMEindicatesthecodeiswaitingforanotherresourcetobeavailable,suchaswaitingforasynchronizationobject,waitingforat

c# - Dispatcher.BeginInvoke ,尝试使用 lambda 从文本 block 获取字符串集,但出现转换错误

我试图从按钮调用选定的列表框项目,而不是wpf中的listbox.selecteditemchanged方法。所以当我尝试stringyadda=listbox.SelectedItem.ToString();我得到一个异常(exception):Thecallingthreadcannotaccessthisobjectbecauseadifferentthreadownsit.所以,我想做的是:Dispatcher.BeginInvoke(()=>{lbxSelectedItem=(lbxFileList.SelectedItemasTextBlock).Text;});这也不起作

c# - UInt64 和 "The operation overflows at compile time in checked mode"- CS0220

这感觉像是一个愚蠢的问题,但我似乎看不到答案。我有一个UInt64,它的最大值应该是UInt64.MaxValue18446744073709551615但是,当我尝试分配一个中等大小的数字时,出现“在检查模式下编译时操作溢出”的溢出错误。如果我将它包装在一个“未经检查”的block中,那么它会编译并运行,就像这个变量为零一样:UInt64value1=1073741824*8;//CompileerrorCS0220UInt64value2=8589934592;//Actualvalue-noerror为什么会这样? 最佳答案

c# - 以管理员身份运行 : requireAdministrator & ClickOnce + emulating system time

我的应用程序使用ClickOnce技术。今天我需要以管理员身份运行它。我修改了来自的list文件到但是VS无法编译项目:Error35ClickOncedoesnotsupporttherequestexecutionlevel'requireAdministrator'.我认为不可能同时使用它们。不是吗?我需要更改系统时间,我可以在应用程序级别进行吗?我可以模拟它吗,所以应用程序。可以做我想做的事。我将时间更改为+2小时,然后再放回去一秒钟。我有一些dll,他们需要时间。 最佳答案 实际上,您不能使用管理员权限运行ClickOnc