Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spawn separate process independent of PageLoad

Status
Not open for further replies.

benjatado

Programmer
May 15, 2005
52
0
0
US
Hi -

I am having a sick time trying to spawn a separate process independent of pageLoad

Background:

I have a site where files are requested from. Upon hitting "submit" requested files are written to db and file.copied to the storage location where the user will return to download (at a later time).

The problem I am having is the "wait-time" that is created while this file.copy method does it's work.

Regardless if I put the file.copy within the OnClick or PageLoad of the result.aspx - it still hits and slows everything down.

Are there any recommendations on how to spawn a file.copy()as a separate independent method that does not interfere with the pageload of the results page?

Thanks in advance!!
 
If you try to do it within the same context of the page, then it will wait until everything is complete before sending the response back to the client (i.e. irrelevant of where you put the code). You would at least need to do this as a seperate thread, or even better delegate the work off to another service that does the work.

Mark,

[URL unfurl="true"]http://lessthandot.com[/url] - Experts, Information, Ideas & Knowledge
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Website Design
[URL unfurl="true"]http://aspnetlibrary.com[/url] - An online resource for professional ASP.NET developers
 
Thanks Mark!

I was afraid of that ;)

Delegates are a bit confusing to me.

So if I want to establish a delegate, can I pass it to another class and sub along with multiple parameters/values?

ie:
FileSetup.CopyFileRoutine(filepath, destination)

And the subsequent pageload routine will go on with it's business after firing off the delegate?

Thanks again!


 
not delegates as in Delegate objects. delegate as in have another object do the work
Code:
public void dosomethingwith(string file)
{
   var file = service_1.Create(file);
   service_2.load_file_to_database(file);
   service_3.nofity_some_about(file);
}
this still happens in sequence. if you want to kick off this process without waiting for completion and return to the client with a "pending" message. then you are getting into distributed systems.

there are frameworks which handle this, but the concepts are not easy to grasp. The top 3 are (and are all OSS)
MassTransit
Rhino.Service.Bus
NServiceBus

NSBis the most mature, but requires the most hands on configuration. RSB is built with to reduce as much friction as possible. it is also highly opinionated about how use consume it. I don't know much about MT, but the devs behind it are solid and have put a great amount of effort into the project.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Ok, thanks for both of your replies.

Could I point to a separate build/process (exe or bat) outside from within the pageload without triggering any kind of waitforexit event of that external process?

I am thinking I may be able to easily kick off another process that retrieves session and file location data logged into the db and perform the file copy routine after or "behind the scenes" of the pageloads of the site.

Let me know if you think this may work?

Thanks again!
 
It's fairly easy to kick off an external process:


However, it really depends on whether you need feedback from that process as to how you implement the execution of said process. If you don't need any feedback at all, then just go ahead and use the method in the link above.

Mark,

[URL unfurl="true"]http://lessthandot.com[/url] - Experts, Information, Ideas & Knowledge
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Website Design
[URL unfurl="true"]http://aspnetlibrary.com[/url] - An online resource for professional ASP.NET developers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top