I am using ASP.NET MVC 3 with C# and I am having a process that takes about 10 minutes to be finished. I need some help how could I show some interface (progressbar, etc).
What would happen if user turned the browser off? My process should not be stopped.
What would happen if another user tried to open the process page?
I started searching about jQuery progress bar but got those questions and looking for some help.
Thank you
If your process takes 10 minute to finish, then you must make the work on background, and keep the result somewhere to show it.
First question: What happend if the user close the browser, to solve this, you need to create a system to make the work on backgroud and leave the browser to continue. if can not make a full shedule class to make your works, a simple thead can do the same think - but is less flexible.
Second question: How to avoid the start of a new process page. You can solve this by using mutex. You set a mutex with a specidic name, and you close it when the job done, after 10minute. In the middle if some user try to re-run the same process you see that the mutex is lock and you show him a message to wait.
You need somewhere to keep the result information's, eg, Let say that you make a job of 10 minute, then store the results somewhere and the user see the results and when they are generated and if he like can rerun the procedure.
With this I describe you to not need to fully disable the page, just a message that result still running, or an automatic refresh to the page every 30 seconds to see if they are done.
Related
I am loading something that takes a long time in OnPaint function the first time I run my program, and I need a way to show my progress. I already have the progress stuff up, but I just don't know the simplest way to show it.
Want either
Something to keep the form responsive when stucked in OnPaint function for a prolonged period, I am changing the title name to show progression and I want the form to stay responsive!
Pop up something else that is easily created to show progress
btw, I am loading it only OnPaint because I wanted the form to show up so that the user will know that the program opened correctly. Otherwise nothing will happen while the form loads, and the user might think that the program was not even opened.
There is not a lot of context here, but if I understand correctly it appears that you have something that needs to happen when the form loads and it might take a long time. You are trying to do this in the paint event because you want to make sure that the user sees something while whatever is loading completes.
Is that assessment correct?
If so, I recommend that you consider the BackgroundWorker class as it will let you do the expensive 'loading' you discuss while keeping the UI responsive.
The example with the documentation does a great job so I'll not write another sample here...
BackgroundWorker Class
Chris
DoEvent
As per mentioned by Jeremy Thompson, many thanks
Though I need to wait 2 days to be able to accept this answer.
I would like to set up a persistent state for my application. Let me explain.
The startup time is kinda long (mostly due to many database requests to a remote server, which take 5 - 10 seconds, and even more since my users usually have too much applications running...) and I'd like to set up a way to hide & show my application when needed.
What I am doing now is to only reduce app to tray when user clicks on the red cross. (The application really exits only when a user chooses File -> Exit).
All users are launching an installer which is checking the version installed, then the version available online, and update the app if needed before launching it.
Now, I'd like it to first check on the process monitor (the one found in Task Manager, Processes tab), and if a process is already running for the application, it'll just show the window again. Otherwise, if no process is running, we can process the classic-check-for-update-then-launch steps.
This would especially remove a lot of stupid customer requests I regularly have ("hey, your application takes too long to load, so I clicked on it again 5 times and it launched 6 instances!!!!" :/ ) and therefore save me a lot of useless time spent asking them to stop launching 50 instances of the same application cause it won't make it any faster...
So my main question is: how to perform such a trick in C#/WPF?
For now, my minimization process is kinda simple (even though maybe too simple): I just hide the window & the task bar entry. Now I don't know how to show it back from my installer
Any ideas?
Your customers' requests can never be stupid - they pay you money.
To bring window to front - create system wide mutex and check its presence on application startup. If it's there - use interprocess communication mechanisms to send message to that other instance to bring its main window to front (a window message or named pipe - both are fine). Here is an example (make sure to check related answers too).
And by any means show splash screen as soon as you can to prevent relaunching application again and again. If it does not appear in 1-2 seconds (2 is too long) it's bad. Responsiveness of your application makes feeling like it works faster.
Is it something like this you're looking for?
foreach (var p in Process.GetProcesses())
{
if (p.ProcessName.Contains("myProcess"))
{
//process is already running
}
}
Or, with LINQ:
if (Process.GetProcesses().Where(p => p.ProcessName.Contains("myProcess")).Any())
{
//process is already running
}
If the users complain about startup times, maybe consider checking the version on exit, instead of startup.
I have answered a very similar question yesterday. The only bit that's missing there is how to hide and show the window: use Window.Visibility, set it to Visibility.Hidden to hide the window and to Visibility.Visible to show it again.
I am working with the Image generation of a browser, but doing so i am taking a snapshot of the browser from the code, in windows form. But if the browser is not loaded in the specific time (suppose 15 seconds) then a blank snapshot occur. Anyone help me with this .
I'm not entirely sure if I understand exactly what you're trying to do, but I'll take a stab at it: It sounds like you're trying to open whatever program is set as the user's default web browser, and then do something like a BitBlt to take a screenshot of it.
However, as you've noticed, it's difficult to just wait a pre-defined interval and hope the browser has completely loaded. Instead, you could try something like WaitForIdleInput after running the process, which will suspend the thread's execution until the process has finished initializing and is idle (waiting for user input). This should allow the browser to finish loading before you proceed with taking the snapshot.
Something like the following code:
//start the web browser
System.Diagnostics.Process proc = System.Diagnostics.Process.Start("iexplore.exe");
//wait for it to completely finish loading
proc.WaitForInputIdle();
//take your screenshot, or whatever
//...
I'm trying to make a web browser that tells me when a specific video is done. I already know how to get the time in seconds of how long it takes. I just need to know how to wait to execute the next step without stopping the webbrowser control (which needs to play the flash video).
Any ideas? I've been looking into the Timer class, but can't figure out how to apply it to this problem.
Thanks.
Well, you could try Thread.Sleep() (You're not clear about what threads are running what...), except this idea is doomed to failure. I mean, you are going to let him pause the video, aren't you?
(Yes, You are!)
I wrote a webcrawler which calls a web page in a do while loop amount 3 seconds
totally there are 7000 sites... i parse the data and save it in my DB.
sometimes because the script is loading for a long time, i got a timeout in browser,
but in background i continues. I see that on my database.
Can I prevent this?.. Now it's just possible if I stop webserver.
Thank you and best regards.
Your web page is kicking off a server-side process. Killing your browser or closing it is not going to stop this. It sounds to me like a web page to control this is the wrong approach, and you should be looking at a connected form of application like a WinForms/WPF app. There would be ways to get this to work with ASP.NET, but they are not going to be simple. I think you have just chosen the wrong technology.
Starting an intensive, long running process like this from a web page is almost never a good idea. There are lots of reasons, but the main ones are :
1) If you get a timeout in the browser (this is your scenario) the data you have harvested may not be displayed.
2) What happens if you hit refresh in the browser? Will it attepmt to start the whole process again? this is an easy target for an attacker, if he wants to tie up all your server resources.
3) Is the data you are crawling really likely to change to such an extent that you need "live" crawling? 99% of cases would be served just as well with a background timed job running the crawl, and your front end just displaying the contents of the database.
I would seriously recommend you rethink your crawling strategy to something more controllable and stable.