jjzjj

multiple-dispatch

全部标签

c# - 等效于 Dispatcher.Invoke 或 Dispatcher.RunAsync 的可移植类库

在.NET、Windows8和WindowsPhone7中,我有类似这样的代码:publicstaticvoidInvokeIfRequired(thisDispatcherdispatcher,Actionaction){if(dispatcher.CheckAccess()){action();}else{dispatcher.Invoke(action);}}我将如何在可移植类库中做一些事情?最好有一个与平台无关的实现。我的想法是使用WP7中不可用但肯定会很快的TPL。//PortableDispatchermustbecreatedontheUIthreadandthenmad

c# - Asp.Net 路由 : How do I ignore multiple wildcard routes?

我想忽略多个通配符路由。在asp.netmvcpreview4中,它们附带:RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");我还想添加如下内容:RouteTable.Routes.IgnoreRoute("Content/{*pathInfo}");但这似乎破坏了一些在我的程序中生成url的助手。想法? 最佳答案 这里有两种可能的解决方案。向忽略路由添加约束以确保只有应忽略的请求才会匹配该路由。有点笨拙,但应该可以。RouteTable.Routes.Ignor

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# - 为什么每个 Dispatcher.BeginInvoke 回调都有一个唯一的同步上下文?

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

c# - Youtube 数据 API : Retrieving multiple Video entries by IDs in a single request

我想知道是否有办法在YouTube上查询多个随机单个查询中的视频(视频ID已知)?我将视频ID存储在本地数据库中,需要显示多个网页中的详细信息(带有拇指、评分、作者姓名等的列表)。我正在查看Youtube数据API,发现我可以像这样的实体数据:UrivideoEntryUrl=newUri("http://gdata.youtube.com/feeds/api/videos/video_id");Videovideo=request.Retrieve(videoEntryUrl);在循环中重复这个似乎是个坏主意,因为配额。还有“批处理”可用——http://code.google.co

c# - Dispatcher.BeginInvoke 问题

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

c# - WPF Dispatcher BeginInvoke 排序保证

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

c# - LINQ TO 数据集 : Multiple group by on a data table

我正在使用Linqtodataset来查询数据表。如果我想对数据表的“Column1”执行分组,我使用以下查询vargroupQuery=fromtableinMyTable.AsEnumerable()grouptablebytable["Column1"]intogroupedTableselectnew{x=groupedTable.Key,y=groupedTable.Count()}现在我想对两列“Coulmn1”和“Column2”进行分组。谁能告诉我语法或提供一个链接来解释数据表上的多个分组依据??谢谢 最佳答案 您应

C# Generic List of Multiple Types 泛型列表

这是我的问题的抽象和简化:我有一套玩具和这些玩具对应的盒子。我希望用户能够指定盒子可以容纳的最大类型的玩具:publicclassBox{}然后在Box类中我想要一个通用的玩具列表,但是盒子中包含的每个玩具都有一个通用类型:publicclassBox{publicList=newList();publicboolWhatever;[memberfunctions,constructors...][ThememberfunctionswilldependonT]}Toys类将如下所示:publicclassToywhereT:struct//Tisanytype{publicList=

C# Linq : Combine multiple . Where() with an *OR* 子句

我一直在搜索有关我当前问题的大量信息,但找不到解决该问题的真正答案。我正在尝试构建一个生成以下SQL的LINQ查询:SELECT*FROMTABLEWHERE(Field1=X,Field2=Y...)or(Field3=Z)在正常情况下我会这样做:Object.Where(c=>(c.Field1==X&&c.Field2==Y)||(c.Field3==Z))我不能使用这种方法,因为查询是通过使用多个.Where()调用构建的。举个例子://Thisisashortexample,therealworldsituationhas20fieldstocheckandtheyareal