views:

519

answers:

1

Hello everybody,

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

A: 

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

ctacke
Unfortunately I may not use third party libraries, but I've managed to use the MessageWindow class for receiving asynchronous status messages.
Thorsten Dittmar
ok, so I call that a stupid rule. If the source is freely available, why couldn't you us it? For the sake of making you waste time writing the code yourself? THere's zero value in that unless you want to be a RAS expert.
ctacke
True - a stupid rule. But haven't all of us met stupid requirements during our career? ;-) I'll accept your anser anyway, as it is a perfectly good advice I'd have followed, if not for that stupid requirement.
Thorsten Dittmar
But the question is, if you have source code and use it, how exactly is that different than if you wrote the exact same code yourself?I suppose you could always look at the code and manually type the same thing as well.The reality is that there is only one API set for RAS, so by that very fact, you have to end up with essentially the same code as the existing RAS library. One simply wastes a lot more of your time.
ctacke