long running processes & notifications

long running processes & notifications

Old forum URL: forums.lhotka.net/forums/t/6400.aspx


rfcdejong posted on Wednesday, February 11, 2009

We'll use long running procesesses in our application for sure, which ofcourse should not lock the mainthread. ASync operations with the server while the client stays responsive. Mostly having a process dialog with a processbar or else something to let the user believe the program is busy and not dead.

My guess goes out in using the CommandBase class to execute code on the dataportal, but that won't be in a differend threat.

Is there anyone with experience using async operations in CSLA?

Start a BGW and on the DoWork call the command? Then update the progress bar with messages from the server (ohoh).

sergeyb replied on Wednesday, February 11, 2009

3.6 has asynch portal functionality. You can just have two commands - one that does the work, the other that you launch in a look to get progress value of sorts from DB. This is probably the easiest route to go. Although you need to be aware that if the user exists the app you might have issues.

Sergey Barskiy
Principal Consultant
office: 678.405.0687 | mobile: 404.388.1899

Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

-----Original Message-----
From: rfcdejong [mailto:cslanet@lhotka.net]
Sent: Wednesday, February 11, 2009 3:14 PM
To: Sergey Barskiy
Subject: [CSLA .NET] long running processes & notifications

We'll use long running procesesses in our application for sure, which ofcourse should not lock the mainthread. ASync operations with the server while the client stays responsive. Mostly having a process dialog with a processbar or else something to let the user believe the program is busy and not dead.

My guess goes out in using the CommandBase class to execute code on the dataportal, but that won't be in a differend threat.

Is there anyone with experience using async operations in CSLA?

Start a BGW and on the DoWork call the command? Then update the progress bar with messages from the server (ohoh).

rfcdejong replied on Thursday, February 12, 2009

Ok, that is something i might continue with, i'll dive deeper into this for sure. I must :)

Unless someone knows that this won't work cause of serialization problems etc?
Threats in C# are kinda simple, invoking the main threat etc from an background isn't hard, just something u need to know when u are using it. No need for using mutexes, semaphores, etc..

The dataportal in CSLA makes it differend, there must be some communication meanwhile between the client and the server.

Until later...

RockfordLhotka replied on Thursday, February 12, 2009

The question is push vs pull.

If you want the server to push a message to the client, that's hard. The reason, is this means that the server must be able to open an IP connection to the client, and typically a client does not have a routable IP address (the server can't ping the client).

Windows Azure .NET Services (or whatever the current name is - used to be Biztalk Services) solve this using the same sophisticated technology used by chat programs, online games, etc. I think the book Gaming Gems 4 (or 5?) has a chapter discussing the low level networking code you need to write to allow a server to punch a hole through most NAT/firewall scenarios - it is gory.

The other alternative is for the client to open a persistent IP socket connection to the server. You can't do this over HTTP, because HTTP doesn't allow it. But you can do it with TCP, and there may be a WCF channel that works this way (dualTcp?). It would be interesting to see whether this would work through the data portal. It might, if you put the callback reference into Csla.ApplicationContext.ClientContext.

If you want the client to pull a message from the server, that's easier. In this case, the client polls the server for messages and processes any it gets. This is how the Silverlight dualHttpBinding works in WCF btw - they just continue to poll the server to get messages.

You could do this with the data portal too, though you'd have to figure out a way to share state between the original (long running) request and the subsequent get status requests. In a balanced web farm these could run on different machines, so you probably need to maintain the shared state in a database table or something.

rfcdejong replied on Thursday, February 12, 2009

The strange thing is there isn't nearly any related question about this on the forum, hasn't anyone else ever ran into a situation like this.

About a balanced web farm, i think there will be strange, unforseen errors.

I guess u are right about pulling messages is easier.
Thanks for the insight!

Copyright (c) Marimer LLC