将数据传递到服务器进行计算 [英] Passing data to server for computation

查看:103
本文介绍了将数据传递到服务器进行计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#创建程序,该程序可在台式机上运行,​​但在某些情况下能够将变量和对象传递给服务器。然后,服务器将处理变量,然后将结果返回到桌面上的程序以进行进一步处理。

How do I create a program in c# that runs on a desktop but on certain occasions, is able to pass variables and objects to a server. The server will then process the variables before returning the outcome to the program on the desktop for further processing.

因此,例如,我想将double和3.5和4.5传递给服务器。然后,服务器将添加3.5和4.5,以将8返回到桌面上的程序。然后,桌面上的程序将进一步使用8。

So for e.g., I want to pass the doubles 3.5 and 4.5 to the server. The server would then add 3.5 and 4.5 to return 8 to the program on the desktop. The 8 will then be further utilised by the program on the desktop.

我必须编写两个单独的程序吗?一台在服务器上,一台在台式机上。如果是这样,我该如何链接它们。即如何将数据从台式机上的程序传递到服务器上的程序,反之亦然?

Do I have to write two separate programs? One on the server and one on the desktop. And if so, how do I link them. i.e. how do I pass data from the program on the desktop to the program on the server and vice versa?

非常感谢您的帮助。

推荐答案

您不需要两个不同的程序。虽然这样比较容易,但是您可以坚持使用以不同模式运行的计算机。

You do not need two different programs. While it is easier that way you can stick with one that runs in different modes.

WCF ,<$ c可以使用$ c> WebApi , ServiceStack MessageBus

但是您正在一次跳跃,很难一次实现。

But you are making a jump that is hard to achieve at once.

您有一个同步的本地应用程序(所有运行在一个应用程序中),而您想访问一个异步远程应用程序(所有内容都并行化并在另一台计算机上执行)。
WCF 等为您提供了一个简单的开始,但是我建议您使用更小的步骤,因为它不能缓解所有问题。

You have a synchronous local application (everything runs in one app) and you want to get to an asynchronous remote application (everything is parallelized and executed on a different machine). WCF etc. gives you an easy start, however I would recommend smaller steps as it does not mitigate all issues.

首先保留您的同步应用程序并使它异步。因此,它在多线程环境中向自己发出一些消息(比如说两个双打),并等待它而不会阻塞。

First keep your synchronous application and make it asynchronous. So it issues some message (say the two doubles) to itself in a multi-threaded environment and waits for it without blocking.

这引入了自己的一系列问题(线程,等待,锁定)。

This introduces its own set of issues (threading, waiting, locks).

完成后,应将功能外部化为单独的应用程序或在服务器模式下运行的同一应用程序,从而导致异步本地应用程序。
在这一步中,您已经跨应用程序边界,同时已经实现了线程化并且仍然是本地的。

After you've done that you should externalize your functionality to a separate application or the same application running in a "server" mode, resulting in an asynchronous local application. In this step you cross application boundaries while already having achieved threading and still being local.

完成此操作之后,请开始考虑放置服务器应用程序在远程计算机上进行处理(通信,资源可用性,协议等)。

After you've done that, start thinking about placing the server application on a remote machine and deal with that (communication, resource availability, protocols, etc.)

每个步骤都很复杂。通过一次完成所有操作,您将需要处理多线程,阻塞应用程序, WCF 的复杂性,连接处理(超时,代理,不可用资源,连接中断等)。并同时外包处理。

Each step is complex. By doing everything at once you will need to handle multithreading, blocking application, the complexity of WCF, connection handling (timeouts, proxies, not available resources, connection interrupts, etc.) and outsourced processing at the same time at once.

这篇关于将数据传递到服务器进行计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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