草庐IT

last_lock_in_thread

全部标签

c# - ASP.NET : Check for click event in page_load

在C#中,如何检查是否在页面加载方法中单击了链接按钮?我需要知道在触发点击事件之前它是否被点击。 最佳答案 if(IsPostBack){//getthetargetofthepost-back,willbethenameofthecontrol//thatissuedthepost-backstringeTarget=Request.Params["__EVENTTARGET"].ToString();} 关于c#-ASP.NET:Checkforclickeventinpage_lo

c# - 并发集合在没有 Thread.Sleep 的情况下吃太多 cpu

BlockingCollection或ConcurrentQueue的正确用法是什么,这样您就可以自由地使项目出队,而不会使用线程消耗一半或更多的CPU?我正在使用2个线程运行一些测试,除非我有至少50~100毫秒的Thread.Sleep,否则它总是会占用至少50%的CPU。这是一个虚构的例子:privatevoid_DequeueItem(){objecto=null;while(socket.Connected){while(!listOfQueueItems.IsEmpty){if(listOfQueueItems.TryDequeue(outo)){//usethedata}

c# - "Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF"带复合键

我们最近向我们的数据库添加了一个新的“级别”——在整个数据库中的表中现有ID身份字段的上方/之前添加了一个键“Company_ID”。例如,如果一个表有ID然后是字段,它现在有Company_ID,然后是ID,然后是字段。这个想法是,这允许ID为提供给功能的每个不同的Company_ID值自动递增(Company_ID1可以有ID1、2、3等;Company_ID2可以有ID1、2、3等)。自增字段保持为ID。一个示例表是:[dbo].[Project]([Company_ID][int]NOTNULL,[ID][int]IDENTITY(1,1)NOTNULL,[DescShort]

c# - 未经授权的访问异常 : Invalid cross-thread access in Silverlight application (XAML/C#)

C#相对较新,想尝试使用它来使用一些第三方Web服务API。这是XAML代码这是C#代码privatevoidButton_Click(objectsender,RoutedEventArgse){HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create("http://api.twitter.com/1/users/show/keykoo.xml");request.Method="GET";request.BeginGetResponse(newAsyncCallback(twitterCallback),request);}p

c# - "This application can only run in the context of an app container."- Visual Studio 2015 开发新功能

我有点绝望。几个小时以来,我一直在努力解决以下问题。我开发了一个应用程序,我现在尝试使用VisualStudio2015的安装向导扩展来安装它。一切都在构建或(没有错误)但是当我打开应用程序时它突出显示它只能在应用程序容器的上下文中打开。那是什么意思?任何建议将不胜感激!该应用正在使用SQlite数据库。这可能与依赖关系有关吗?如果是这样,我该如何解决这个问题?更新:#Culture="en-US"ConvertFrom-StringData@'###PSLOCPromptYesString=&YesPromptNoString=&NoBundleFound=Foundbundle:{

c# - 将锁与 Threading.Timer 一起使用

我有一个Windows服务应用程序,它使用Threading.Timer和TimerCallback在特定时间间隔进行一些处理。我需要一次将此处理代码锁定到1个线程。因此,例如,启动服务并触发第一个回调,然后启动一个线程并开始处理。只要处理在下一次回调之前完成,这就可以正常工作。例如,处理时间比平时稍长,并且在另一个线程正在处理时再次触发TimerCallback,我需要让该线程等待另一个线程完成。这是我的代码示例:staticTimertimer;staticobjectlocker=newobject();publicvoidStart(){varcallback=newTimer

c# - Thread.Sleep(timeout) 和 ManualResetEvent.Wait(timeout) 有什么区别?

Thread.Sleep(timeout)和resetEvent.Wait(timeout)都会导致执行暂停至少timeout毫秒,那么它们之间有区别吗?我知道Thread.Sleep导致线程放弃其时间片的剩余部分,因此可能导致sleep持续时间比请求的时间长得多。ManualResetEvent对象的Wait(timeout)方法是否有同样的问题?编辑:我知道ManualResetEvent的要点是从另一个线程发出信号-现在我只关心事件的Wait方法指定超时的情况,并且没有其他来电者设置事件。我想知道按时唤醒是否比Thread.Sleep更可靠 最佳答案

c# - OOPS 概念 : What is the difference in passing object reference to interface and creating class object in C#?

我有一个类CustomerNew和一个接口(interface)ICustomer:publicclassCustomerNew:ICustomer{publicvoidA(){MessageBox.Show("Classmethod");}voidICustomer.A(){MessageBox.Show("Interfacemethod");}publicvoidB(){MessageBox.Show("ClassMethod");}}publicinterfaceICustomer{voidA();}我对这两行代码很困惑。ICustomerobjnew=newCustomerNe

C# 帮助 : Sorting a List of Objects in C#

这个问题在这里已经有了答案:关闭13年前。PossibleDuplicates:SortobjectsusingpredefinedlistofsortedvaluesC#Help:SortingaListofObjectsinC#DoublePostSortingaListofobjectsinC#publicclassCarSpecs{publicCarSpecs(){}privateString_CarName;publicStringCarName{get{return_CarName;}set{_CarName=value;}}privateString_CarMaker;p

c# - "Inspecting the state of an object in the debuggee of type System.Reflection.MethodBase is not supported in this context"

我不知道这个错误是什么意思。我使用的是VisualStudioforMac7.5.0社区版。我在带有ASP.NETCore的EntityFramework中使用延迟加载。publicpartialclassAdminUser{publicAdminUser(){RoleAssign=newHashSet();}publicGuidUserId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicstringEmail{get;set;}publicstringUserName{get;s