views:

31

answers:

1

I am having a C# application to sync data between PC and palm devices. There are codes written like below:

  showMessage("synchronizing Table1");

  Sync(destTable1,sourceTable1);

  Sync(destTable2,sourceTable2);

  showMessage("synchronizing Table2");
  // more code

How do I separate the actual process of synchronizing from displaying message? Which design pattern to follow?

Thanks in advance...

+3  A: 

You should run the sync process on a separate thread and inform the main thread of the progress. The main thread displays messages.

You can obtain this behavior using the BackgroundWorker class that has all the feature ready.

ema
I need to know design pattern to decouple both part.Do you have any idea about that?
Manish Gupta
Seems an Observer pattern: the main thread is the subscriber to the events of the sync process thread
ema
thanks a lot...observer pattern can work here
Manish Gupta