等待内部方法直到捕获事件

我在C#中遇到了这个问题。 我做了一个方法,从一个名为Phone.GetLampMode();的DLL调用一个函数Phone.GetLampMode(); 现在Phone.GetLampMode不会返回任何内容。 在’ onGetLampModeResponse ‘事件中返回数据。 有没有办法可以在我的方法中等待,直到我从onGetLampModeResponse事件中获取数据? public bool checkLamp(int iLamp) { Phone.ButtonIDConstants btn = new Phone.ButtonIDConstants(); btn = Phone.ButtonIDConstants.BUTTON_1; btn += iLamp; Phone.GetLampMode(btn, null); return true; } private void Phone_OnGetLampModeResponse(object sender, Phone.GetLampModeResponseArgs e) { var test = e.getLampModeList[0].getLampMode.ToString(); }

Asp MVC Action链接绝对url

我有一组显示给特定用户的视图。 这些是我从我们的应用程序中的其他视图复制的视图,并稍微更改了它们。 在这些视图中我使用的是Html.Action链接,但是我需要这些来返回绝对URL而不是相对。 我知道有额外的参数可以用来获得这种效果,但我不认为它可以改变我所有视图中的所有链接。 理想情况下,我想在一个地方进行更改,并根据需要渲染我的所有链接。 当然必须有我可以设置的东西,或者我可以覆盖的function来实现这一点。

如何在entity framework代码中首先映射不同数据类型的列和实体

我正在使用Entity Framework 5 – Code。 我有一个数据库,我连接到已经存在一段时间了(我没有创建它)。 有一个名为T_Customers的表。 它包含所有客户的列表。 它具有以下结构(仅部分显示): Customer_id | numeric (5, 0) | auto increment | not null (not set as primary key) FName | varchar(50) | not null LName | varchar(50) | not null 我的Customer类: public class Customer : IEntity { public int Id { get; set; } public string FirstName { […]

Winform Treeview按标签查找节点

我有一个树视图,显示成员可能有重复,标签不会。 例: TreeNode node = new TreeNode(itemName); node.Tag = itemID; //unique ID for the item treeView1.Nodes.Add(node); 因此,在搜索时,我知道我可以使用itemName搜索 treeView1.Nodes.Find(itemName, true); 但我怎么能通过标签搜索? treeView1.Nodes.Where没有定义,所以对我来说没有linq 🙁 有关如何按标签搜索的任何建议? :) 谢谢!

使用参数在MVVM Light中打开一个新窗口的最佳实践

我对mvvm和mvvm light相当新,但我想我理解它的一般概念。 我不明白的是,如果我想打开一个新窗口,但该窗口需要来自调用者的数据将这些数据传递到新窗口的最佳做法是什么? 如果我将数据传递给构造函数,那么这意味着我需要在后面的代码中将代码传递给视图模型。 我不能使用消息传递,因为它不是基本数据。 提前致谢。

由于,无法与Linq一起使用.Union

我有点困惑于这个问题。 希望我会得到一些帮助。 这就是重点。 我必须用我的SQL请求填充我的DataGridView: SELECT LOT.NumLot, EtatLot, NomEmploye FROM LOT JOIN AFFECTATION_LOT on LOT.NumLot=AFFECTATION_LOT.NumLot JOIN EMPLOYE on AFFECTATION_LOT.IdEmploye=EMPLOYE.IdEmploye WHERE EtatLot=’Libéré’ or EtatLot=’Suspendu’ or EtatLot=’Démarré’ UNION SELECT NumLot, EtatLot, null FROM LOT WHERE EtatLot=’Démarré’ 首先,我在第二个“SELECT”中使用了“null”值,因为“UNION”需要有3个参数,如第一个“SELECT”,并且我的表LOT中没有“NomEmploye”数据。 无论如何,该请求在SQL中运行良好。 但是当我尝试在LINQ中使用它时 string test = “null”; var listeLotControle = (from x in entBoum.LOT join aff in entBoum.AFFECTATION_LOT on x.NumLot equals aff.NumLot […]

我们如何在WinRT应用程序中设置计时器?

我想在我的Windowsapp store应用中设置Timer。 public void Start_timer() { Windows.UI.Xaml.DispatcherTimer timer = new DispatcherTimer(); timer.Tick += new Windows.UI.Xaml.EventHandler(timer_Tick); timer.Interval = new TimeSpan(00, 1, 1); bool enabled = timer.IsEnabled; // Enable the timer timer.Start(); // Start the timer } 在按钮上单击我调用上面的方法来设置此计时器。 但是当设置了Tickhand的Eventhandler时,我收到错误“尝试读取或写入受保护的内存。这通常表明其他内存已损坏。” 我们是否需要在Windowsapp store应用中以不同方式处理定时器?

显式事件添加/删除,误解?

我最近一直在研究内存管理,并一直在研究如何管理事件,现在,我看到了事件订阅的显式添加/删除语法。 我认为这很简单,添加/删除只允许我在订阅和取消订阅时执行其他逻辑? 我得到它了,还是有更多的东西? 此外,虽然我在这里,任何清理我的事件处理的建议/最佳实践。

.NET核心entity framework – 在类库中为Context添加迁移

我在向.NET Core类库中的Entity Framework数据库上下文添加初始迁移时遇到问题。 当我跑: dotnet ef migrations add migrationName -c PlaceholderContext 我收到错误: Could not invoke this command on the startup project ‘Placeholder.Data’. This version of the Entity Framework Core .NET Command Line Tools does not support commands on class library projects in ASP.NET Core and .NET Core applications. See http://go.microsoft.com/fwlink/?LinkId=798221 for details and workarounds. 所以我点击了链接 […]

Log4net LogicalThreadContext未按预期工作

我一直在尝试使用Log4nets LogicalThreadContext为我的每个日志条目提供上下文。 我的应用程序非常重视async / await,但是从阅读各种文章开始,LogicalThreadContext应该可以与.NET 4.5以后的异步代码一起正常工作。 我正在使用.NET 4.5.1和log4net 2.0.3 我找到了Stephen Cleary关于日志记录和.NET CallContext的一篇很棒的文章 ,结果我决定采用他的代码并使其适应使用log4net,试图查看我的代码中是否有错误可能有一直在引发这个问题。 首先,我完全按原样运行Stephens代码并得到预期的输出 Main 1: Main 1 A: Main 2: Main 2 A: Main 1 A: Main 1 B: Main 2 A: Main 2 B: Main 2 B: Main 2: Main 1 B: Main 1: 接下来,我修改了代码以使用log4net而不是Stephens自定义MyStack internal class Program { private static readonly ILog […]