简体   繁体   English

如何将一些“统计”从c#程序传递到另一个程序?

[英]how to pass some “statistics” from c# program to another program?

I have command-line program that "do a lot of work" and produce "a lot of statistics". 我有“做很多工作”的命令行程序,并产生“很多统计数据”。 It's stocks trading software pretty critical to delays, bugs, and whatever, so I don't want to add GUI to it. 它的股票交易软件对延迟,错误等等至关重要,所以我不想为它添加GUI。 (moreover GUI is required sometimes, but console application should be always launched) (有时需要GUI,但应始终启动控制台应用程序)

I need GUI to friendly display collected statistic (in read-only mode). 我需要GUI来友好地显示收集的统计信息(在只读模式下)。 How to transfer that statistics? 如何转移统计数据? It would be enough to refresh it every second. 每秒刷新它就足够了。 I need to transfer bunch of data from one console c# program to another GUI (probably not c#) program, in future probably by network, but locally for now. 我需要将一堆数据从一个控制台c#程序转移到另一个GUI(可能不是c#)程序,将来可能是通过网络,但现在在本地。

Statistics is like "sensors data", measured every second. 统计数据就像“传感器数据”,每秒测量一次。 There are a lot of (hundreds) of sensors. 有很多(数百个)传感器。 (in real word it's a lot of different values, like "profit", "orders per second" etc.) (实际上,它有很多不同的值,比如“利润”,“每秒订单数”等)

Should I use plain file, db or someting else and how? 我应该使用普通文件,数据库还是其他方式以及如何使用?

You can use any form of IPC (inter-process communication). 您可以使用任何形式的IPC(进程间通信)。

Since you're planning to go over the network in the future, I recommend WCF. 由于您计划将来通过网络,我建议使用WCF。 If the GUI program isn't .NET, then you may need to use a lower-level solution, such as named pipes or sockets. 如果GUI程序不是.NET,那么您可能需要使用较低级别的解决方案,例如命名管道或套接字。

You can try to use a database with a queuing system or a messaging appliance. 您可以尝试将数据库与排队系统或消息设备一起使用。 A server can receive messages to a queue and then the GUI can "subscribe" to the messages. 服务器可以接收消息到队列,然后GUI可以“订阅”消息。

Microsoft Message Queuing Microsoft消息队列

Also you can take a look at memory mapped files: 您还可以查看内存映射文件:

Memory-mapped file 内存映射文件

These can be shared amongst applications simultaneously when configured properly. 正确配置后,这些可以在应用程序之间共享。

Hope that helps, 希望有所帮助,

Jeffrey Kevin Pry Jeffrey Kevin Pry

让“服务器”将其信息存储在数据库中并让“客户端”在需要时进行轮询时,可能会更有效率和更有弹性。

I suggest you look at a technology like DDS . 我建议你看看像DDS这样的技术。 There are no databases involved and it is not hard to implement. 没有涉及数据库,并且实施起来并不困难。 I began looking at OpenSplice DDS recently. 我最近开始关注OpenSplice DDS There are a number of different implementations out there. 那里有许多不同的实现。

This is going way beyond a single comment of course. 当然,这超出了单一评论。 What you will eventually need is a dispatching mechanism to notify subscribers about the data record update. 您最终需要的是一种调度机制,用于通知订户有关数据记录更新的信息。 Since the amount of data is huge, you might not want to opt for a persistence storage. 由于数据量巨大,您可能不希望选择持久性存储。 If the dispatching to multiple subscribers looks overwhelming so far, you can go with a simple interproc (via shared object (aka named pipes) for the consumer-provider to be on the same machine or something more distributed otherwise) 如果到目前为止调度到多个订阅者看起来势不可挡,您可以使用简单的interproc(通过共享对象(也称为命名管道)使消费者提供者在同一台机器上或其他更分散的东西)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM