跨C#应用共享数据 [英] Sharing data across C# apps

查看:174
本文介绍了跨C#应用共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是一件非常简单的事情,但是搜索网络并没有发现任何有用的信息.

我正在VS10下用C#开发.

我需要一种在同一台计算机上的应用程序之间共享计数器(甚至是其他东西)值的方法. On或其他应用程序应该能够锁定和更新计数器.两者都应该能够阅读它.所有应用程序都将关闭,不再需要计数器,尽管有些持久性也可能有用.

如果可以在多个系统之间共享数据,那就更好了……

听起来很简单!

任何帮助表示赞赏.

谢谢
Austin Kalb

This should be a pretty simple thing, yet a search of the net hasn''t turned up anything useful.

I am developing in C# under VS10.

I need a way to share the value of a counter (and maybe even some other stuff) across applications on the same computer. On or the other applications should be able to lock and update the counter. Both should be able to read it. All apps shut down, counter no longer needed, although some persistance might be usefull as well.

If the data could be shared accross multiple systems, that would be even better...

Sounds simple enough!

Any help appreciated.

Thanks
Austin Kalb

推荐答案

如果您使用C#4.0,则会有一个新对象-System.IO.MemoryMappedFile.如果使用的是.Net的早期版本,则可能会在网络上某处找到类似的实现.只需在Google上搜索"C#内存映射文件"即可.
If you use C# 4.0, there''s a new object - System.IO.MemoryMappedFile. If you''re using an earlier version of .Net, you can probably find an implemention of something similar somewhere on the net. Just google "C# memory-maped file".


您可以将数据存储在文本文件中,并在应用程序中读取.
还是使用注册表?
You could store data in a text file and read it across applications.
Or use the registry?


这篇关于跨C#应用共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆