Databinding to CLR property in code

Binding to a Dependency Property is easy in code-behind. You just create a new System.Windows.Data.Binding object, and then call the target dependency object's SetBinding method. But how do you do this when the property which we're binding is a CLR property and you can't provide a DependencyProperty argument to SetBinding ? EDIT: The object implements INotifyPropertyChanged , if

数据绑定到代码中的CLR属性

绑定到依赖属性在代码隐藏中很容易。 您只需创建一个新的System.Windows.Data.Binding对象,然后调用目标依赖项对象的SetBinding方法。 但是,当我们绑定的属性是一个CLR属性并且你不能向SetBinding提供一个DependencyProperty参数时,你怎么做到这SetBinding ? 编辑:该对象实现INotifyPropertyChanged ,如果这是相关的。 绑定目标必须是依赖属性! 这是数据绑定工作的唯一要求! 在这里阅读更多: http://msdn.m

How do I invoke a Delegate faster than by using DynamicInvoke?

Currently I use DynamicInvoke which is very slow. Still using the Delegate type how can I directly invoke the Delegate without late-binding/the DynamicInvoke ? Delegate _method; _method.DynamicInvoke(_args); Thanks. The open source framework Impromptu-Inteface adds an extension method to Delegate called FastDynamicInvoke that runs a little over 20 times faster than DynamicInvoke by using

如何比使用DynamicInvoke更快地调用委托?

目前我使用的DynamicInvoke非常慢。 仍然使用Delegate类型,我怎样才能直接调用Delegate没有迟绑定/ DynamicInvoke ? Delegate _method; _method.DynamicInvoke(_args); 谢谢。 开源框架Impromptu- FastDynamicInvoke为Delegate添加了一个名为FastDynamicInvoke的扩展方法,该方法通过使用DLR而不是反射运行,比DynamicInvoke运行速度快了20多倍。 using ImpromptuInterface ... _method.FastDynamicInvoke(_args);

UWP c# read XML from StreamSocket

I'm trying to communicate with an XMPP (Jabber) server via a TCP network socket ( StreamSocket ) and I'm using the following code to read what the server has send to me: StreamSocket tcpSocket; StreamReader reader; int BUFFER_SIZE = 4096; // Connecting to a remote XMPP server .... reader = new StreamReader(tcpSocket.InputStream.AsStreamForRead()); string result; while (true) { resu

UWP c#从StreamSocket中读取XML

我试图通过TCP网络套接字( StreamSocket )与XMPP(Jabber)服务器通信,并使用以下代码来读取服务器发送给我的信息: StreamSocket tcpSocket; StreamReader reader; int BUFFER_SIZE = 4096; // Connecting to a remote XMPP server .... reader = new StreamReader(tcpSocket.InputStream.AsStreamForRead()); string result; while (true) { result = ""; while (true) { char[] buffer = new char[B

Remove any pending data to read after socket timeout

I'm developing a socket server and a client with .NET Framework 4.6.2 and C#. Client is SynchronousSocketClient . Server class is more or less like this one. On client I send a data to update on database. On server I do a operation in a database (update a table using a stored procedure). The process is client sends data to server, server process it and send back a message with the r

在套接字超时后删除所有待处理数据以供读取

我正在开发一个带有.NET Framework 4.6.2和C#的套接字服务器和客户端。 客户端是SynchronousSocketClient 。 服务器类或多或少是这样的。 在客户端上,我发送数据以更新数据库。 在服务器上,我在数据库中执行操作(使用存储过程更新表)。 该过程是客户端向服务器发送数据,服务器对其进行处理并发送带有结果的消息。 有时候,数据库操作有更多时间来完成它。 当这个时间大于Socket.ReceiveTimeout我得到一个由于

C++ / C# Communication using Named Pipes

Working on a service that needs to do Named Pipe communication between a C# and a C++ application. Eventually the C# will run as a service in session 0, and the C++ as a GUI in the user session. I have created a Named Pipe server class for the C# application, and a Named Pipe client class for the C++ application, along with the necessary GUI to run tests. From what I can see, I am able to con

使用命名管道的C ++ / C#通信

处理需要在C#和C ++应用程序之间进行命名管道通信的服务。 最终,C#将作为会话0中的服务运行,而C ++将作为用户会话中的GUI运行。 我为C#应用程序创建了命名管道服务器类,并为C ++应用程序创建了命名管道客户端类以及运行测试所需的GUI。 从我所能看到的,我能够正确连接。 在连接时,C ++客户端通信线程写入一个初始的“连接”消息,然后等待“已连接”响应。 当调试到两个应用程序的运行时,我都通过两个命名的管道连接

USB Communication, Read Message with Multithreading

I'm having an issue playing something with USB communication. I'm using HidLibrary library, which works beautifully. The only thing that doesn't work is timeout (I already looked on web for a solution but this is a library bug). So, when I send a message and no response comes to PC, my loop runs forever. I am just waiting for bool is message is readed with success or not. If a me

USB通信,多线程读取消息

我遇到了一个与USB通信玩的问题。 我正在使用HidLibrary库,它工作得很好。 唯一不起作用的是超时(我已经在Web上查看了解决方案,但这是一个库错误)。 所以,当我发送消息并且没有回应PC时,我的循环将永远运行。 我只是在等待布尔消息是否成功与否。 如果消息不来,那么呢? 我如何解决这个问题? 使用多线程(WaitHandle类)还是有其他选择?

StreamReader alternative that treats null char (\0) as line ending

I have a client program that receives streaming XML messages from a remote server. These streams provide real-time updates to various sporting events, and it runs forever; even when there are no updates to transmit, it still sends a keep-alive message every 45 seconds. The service in question has two feeds with different details. The first feed terminates each XML message with a carriage-ret

StreamReader替代方案将空字符(\ 0)视为行尾

我有一个客户端程序从远程服务器接收流式XML消息。 这些流提供各种体育赛事的实时更新,并且永久运行; 即使没有更新传输,它仍然每45秒发送一次保持活动消息。 有问题的服务有两种不同的细节。 第一个feed用一个回车符/换行符(0d,0a)终止每个XML消息,这意味着使用StreamReader非常容易。 例如: using (TcpClient Client = new TcpClient(this.Host, this.Port)) { using (NetworkStream stream = Client.GetStream

Example of Named Pipes

How do I write a simple--bare minimum needed for it to work--test application that illustrates how to use IPC/Named Pipes? For example, how would one write a console application where Program 1 says "Hello World" to Program 2 and Program 2 receives message and replies "Roger That" to Program 1. using System; using System.IO; using System.IO.Pipes; using System.Linq; using S

命名管道示例

我该如何编写一个简单的程序 - 最低工作量 - 测试应用程序,说明如何使用IPC /命名管道? 例如,如何编写控制台应用程序,其中程序1向程序2说明“Hello World”,程序2接收消息并向程序1回复“Roger That”。 using System; using System.IO; using System.IO.Pipes; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(st

How to work with named pipes (C++ server , C# client)

I am trying to get started with working with named pipes as I will need to use them for a project of mine in the future. At the moment I have a C++ server which waits until a client connects and sends over a test message. I roughly followed this tutorial to get started. The relevant code is below: #define MESSAGE L"TestMessage" HANDLE hnamedPipe = INVALID_HANDLE_VALUE; hnamedPipe = Cre

如何使用命名管道(C ++服务器,C#客户端)

我正在尝试使用命名管道开始工作,因为我将来需要将它们用于我的项目。 目前,我有一台C ++服务器,等待客户端连接并通过测试消息发送。 我大致遵循本教程开始。 相关代码如下: #define MESSAGE L"TestMessage" HANDLE hnamedPipe = INVALID_HANDLE_VALUE; hnamedPipe = CreateNamedPipe( L"\\.\pipe\testpipe", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE| PIPE_READMODE_MESSAGE| PIPE_WAIT,

Targeting multiple .NET frameworks in a single binary?

The Background: I have an application that needs to run on clients whose installed .NET frameworks range all the way from 2.0 up to 4.5. This application has to be able to enumerate and perform operations on large numbers of files (in excess of 200k discrete files, in select cases). To build the index of files, the application currently uses System.IO.DirectoryInfo.GetFiles(). This comes at

在一个二进制文件中定位多个.NET框架?

的背景: 我有一个应用程序需要在已安装的.NET框架范围从2.0到4.5的客户端上运行。 此应用程序必须能够枚举和执行大量文件的操作(在特定情况下超过200k个离散文件)。 要构建文件的索引,应用程序当前使用System.IO.DirectoryInfo.GetFiles()。 这是性能问题,因为处理组件在开始工作之前必须等待整个Path树进行索引。 由于一些古老的磁带多路加载器和一些写得不好的固件,遍历一些目录可能会触发从磁带读取 - 将处理