开发者

C#: How to cancel RasDial call?

we are using C# with the .NET Compact Framework 2.0 on a Windows CE 6 device. I'm using the RasDial call to establish a GPRS connection when I need to transfer data between a server and the device.

This all works nicely. However, sometimes when there's no signal, the call to RasDial takes forever and can only be stopped by warm-booting the device. Our customer would like me to add a "Cancel" button to the status window we're displaying to allow the user to cancel the dial process.

Question is: How? RasDial is a synchronous call and I don't see a way of cancelling the request. One solution would be to perform the call in a separate thread and just abort that thread when the user presses the "Cancel" button, but that does not seem to be a very nice solution.

Any thoughts?

EDIT

Currently I'm trying to add functionality to a C++ Library I've added to the project anyways, which would allow me to use RasHangup to cancel the dial (make asynchronous call to RasDial).

Any thoughts on how I'd do this with standard C#/.NET Framework without a separate C++ DLL or third party library?

EDIT 2

Just discovered the MessageWindow class in .NET Compact Framework 2.0 - I'll try to use a subclass of this to receive status messages.

EDIT 3

I've worked out how to use MessageWindow for my needs and I can now get notified asynchronously about the connection process. Seems开发者_开发百科 I've solved it myself :-D


You might take a look at the OpenNETCF RAS library over on CodePlex. It has all of this done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜