Doing things in a thread

L

Lars Black

Hi,

I'm about to start a new CF.NET application where I like to use threads.
Since I've not used thread in CF.NET before, I'd like some input to see if
it is possible to do what I plan to do.

The application will be using SQLCE and will receive data updates via a web
service. Id like the updating to run in a thread so the user should not
worry about it.

Thread-pseudo code:
* Connect to web service via GPRS. This uses a WebHTTPRquest and will
(normally ;-) initiate the dial-up automatically
* Process the data recivede from the web service and update SQLCE
accordingly
* If updates were received, somehow notify the main thread that it needs to
refresh it's GUI. I'm not sure how to do this, so any ideas would be
appreciated.

Would that cause me any troubles? Especially using SQLCE from two thread at
the same time..

Cheers,
Lars
 
J

Jimmy

As far as i know, its not much of a difference than if you did it for a
normal application. There are some things you cant do, but try to look at
the System.Threading namespace. That should get you on the way.

Regarding the main thread, you might want to look at Invoke. Im no expert at
this, but i think its allmost the same as for a normal desktop application.

I recon many of the guys in here will mention the opennetcf, wich has
extended functionality for threading.

Hope this helps
 
A

Alex Feinman [MVP]

Using SQL CE from two threads will most likely require you to implement some
sort of synchronization mechanism. For example since you only can have one
connection at a time, you will probablly use a single SqlCeConnection
object. When doing this enclose the code that accesses DB in
lock(conn)
{
}
This way you will avoid concurrency problems
 
L

Lars Black

This way you will avoid concurrency problems

Thanks, much appreciated!

Cheers,
Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top