服务方法的 GUI
我们有一项服务,可以按指定的时间间隔运行用于数据导入/导出的方法。 为了测试这些方法,我们有一个带有单个按钮的小应用程序,单击该按钮时,会实例化导入/导出类并调用所需的方法。 没有什么花哨。 我想创建一个更强大的测试应用程序,它可以比从服务方法的返回值更实时地从方法接收调试信息。 这些方法可能需要几分钟到 30 分钟才能运行完整的导入/导出负载,并且我想要一些有关已处理的数据量的指示。
我最初的想法是将这些类包装在某种类型的消息队列类中,然后测试应用程序可以从中读取并显示消息。 然而我对此仍然是个新手,所以我不知道是否有更好的方法来做我想做的事情。
我们在 .NET 2.0 上使用 VB 进行开发
We have a service that runs methods used for data import/export at specified intervals. To test these methods we have a little application with a single button that, when clicked, instantiates the import/export class and invokes the desired method. Nothing fancy. I would like create a more robust test application that can receive debug information from the method in more of a real-time fashion than the return value from the service method. These methods can take anywhere from a few minutes to 30 to run a full import/export load, and I would like some indication of the amount of data that's already been processed.
My initial idea was to wrap the classes in some type of message queuing class which the test application could then read from and display the messages. However I'm still kind of a n00b at this, so I don't know if there's a better way to do what I want to do.
We develop in VB on .NET 2.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以修改服务方法以引发在处理过程中报告状态的事件,然后只需处理代码中的事件即可更新状态,这将是最快的方法。
您的生产代码根本无法对事件执行任何操作
You could modify your service methods to raise events that report on status during the processing then simply handle the events in your code to update the status, that would be the fastest method.
Your production code could simply not do anything with the events
也许您可以使用BackgroundWorker 对象使用服务中的调试信息来更新您的应用程序。 BackgroundWorker 的好处是它在单独的线程上运行代码,这使得您的表单可用于更新。
使用BackgroundWorker 将允许您使用来自服务的调试信息来更新应用程序,从而允许您在进程运行时查看更多信息。 在“DoWork”方法中启动进程,当有要显示的调试信息时,调用“ProgressChanged”方法。 在“ProgressChanged”方法中,您可以使用调试信息更新表单。
让我知道这是否有帮助!
JFV
Perhaps you can use a BackgroundWorker object to update your application with the Debug information from your service. The nice thing about BackgroundWorker is that it runs the code on a separate thread which leaves your form available for updates.
Using the BackgroundWorker will allow you to update your application with debug information from the service allowing you to see more information while the process is running. Start the process in the 'DoWork' method and when there is debug information to be displayed, invoke the 'ProgressChanged' method. In the 'ProgressChanged' method, you can update your form with the debug information.
Let me know if this helps!
JFV