How To Run A Process On A Timed Interval

Apr 19, 2010

In an ASP.NET website, how would I run a process, such as send an email, on a timed interval?

Lets say send myself an email every 4 hours. And assume there is no activity at all on the website during that period.

The only way I can think of doin it is open a web page on the site and have it refresh at a timed interval that is less than the server time out setting. When the page refreshes check to see if it is time to send the email, if so send it.

View 1 Replies


Similar Messages:

Configuration :: Process.start (System.Diagnostics.Process) - Execute A Batch File

Sep 7, 2010

I've written a aspx.net(C#) page that after the user has done what they do on the page they hit a Submit button. The Submit button

1) takes the work the users was producing on the page and writes it to a file.
2) attempts to execute a batch file.

The call to the batch file is executed via:

protected void Execute123EDI()
{
try
{
string File = @"c:80sAdminSendV80s.bat";
lblCancelled.Text = lblCancelled.Text + File;
Process proc = new System.Diagnostics.Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.LoadUserProfile = false;
proc.StartInfo.UserName = "administrator";
proc.StartInfo.RedirectStandardOutput = true;
System.Security.SecureString secPass = new System.Security.SecureString();
string paswd = "123abc";
for (int i = 0; i < paswd.Length; i++)
{
secPass.AppendChar(paswd[i]);
}
proc.StartInfo.Password = secPass;
proc.StartInfo.FileName = File;
proc.Start();
FileStream fs = new FileStream(@"c:80sAdminSendV80sOutput.log", FileMode.Append);
StreamWriter sw = new StreamWriter(fs);
sw.Write(proc.StandardOutput.ReadToEnd());
proc.WaitForExit();
sw.Close();
proc.Close();
}
catch(Exception ex)
{
lblDebug.Text = lblDebug.Text + ex.Message + "<br/>";
}

If I watch the processes tab in Task Manager on the web server I see "cmd.exe" under the context of 'administrator' but it just hangs. For test purposes c:SendV80s.bat: copy c: oot.ini c:zzz.txt

If I logon onto the webserver's console and execute SendV80s.bat it works and exits without issue. But when I execute the same batch file via the Submit button it gets stuck executing in Task Manager/Process. I believe this has something to do with the fact that cmd is not running in a full environment/desktop context. I just noticed this on the actual console of the webserver (not in my RDP console but console 0 instead)

A pop-up box stating: CMD.exe Application error The application failed to initialize properly (0xc0000142). Click OK to terminate the application. And when I click on the OK button my ASPX page's WaitForExit is satisfied and the continues processing normally.

View 2 Replies

Long Running HTTP Process - How To Put In Separate Process

Jul 21, 2010

I know that similar questions have been asked all over the place, but I'm having trouble finding one that relates directly to what I'm after.

I have a website where a user uploads a data file, then that file is transformed and imported into SQL. The file could be up to 50mb in size, and some times this process can take 30 minutes or sometimes even longer.

I realise I need to palm off the actual work to another process, and poll that process on the web page. I'm wondering what the best approach would be though? Being a web developer by trade, I'm finding all this new Windows Service stuff a bit confusing, and I just wanted somewhere to start.

So:

Can I do / should I being doing this with a windows service? if so, how?

Should I use WCF? If this runs under IIS, will I have problems with aspnet_wp.exe recycling and timing out my process?

clarifications

The data is imported into sql, there's no file distribution taking place.

If there is a failure, it absolutely MUST be reported to the user. The web page will poll every, lets say, 5 seconds, from the time the async task begins, to get the 'status' of the import. Once it's finished another response will tell the page to stop polling for status updates.

queries on final decision

ok, so as I thought, it seems that a windows service is the best idea. So as to HOW to get it to work, it seems the 'put the file there and wait for the service to pick it up' idea is the generally accepted way, is there a way I can start a process run by the service, without it having to constantly be checking a database table / folder? As I said earlier, I don't have any experience with Windows Services - I wondered if I put a public method in the service, can I call it somehow?

View 2 Replies

Execute A Process Remotely With System.Diagnostics.Process

Feb 26, 2010

I'm working on an ASP.net app I'm trying to execute a process remotely , using System.Diagnostics.Process class here's my code:

ProcessStartInfo startInfo = new ProcessStartInfo(@"C:TestCommand.exe");
startInfo.Domain = "myDomain";
startInfo.UserName = "MyUserName";
SecureString sec = new SecureString();
foreach (char item in "MyPassword")
{
sec.AppendChar(item);
}
sec.MakeReadOnly();
startInfo.Password = sec;
startInfo.UseShellExecute = false;
Process.Start(startInfo);

I keep receiving an exception with the message "Logon failure: unknown user name or bad password". Im absolutelly sure that i'm submiting my correct username/pwd

View 1 Replies

Web Forms :: The Process Cannot Access The File 'c: Empmy.pdf' Because It Is Being Used By Another Process?

Apr 3, 2010

I've developed a popup email .aspx used on our intranet based web app that is auto generated with .pdf's attached. I'm developing with VS 2008 ASP.Net 3.5 C# and System.Net.Mail.MailMessage. I can create and send the email with no issues. The problem is with any attempt to open or delete the attachments I get the above error. The .pdf's a copied with the following code:

FileStream fsr = new FileStream(inFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryReader reader = new BinaryReader(fsr);
byte[] bytes = new byte[fsr.Length];
reader.Read(bytes, 0, bytes.Length);
FileStream fsw = new FileStream(outFileName, FileMode.Create, FileAccess.Write, FileShare.Write);
BinaryWriter writer = new BinaryWriter(fsw);
writer.Write(bytes, 0, bytes.Length);
// clean up
writer.Flush();
writer.Close();
writer = null;
fsw.Close();
fsw.Dispose();
fsw = null;
reader.Close();
reader = null;
fsr.Close();
fsr.Dispose();
fsr = null;
Later after sending the email I:
mailMessage.Dispose();
mailMessage = null;
foreach (string fileName in attachments)
{
if (File.Exists(fileName))
File.Delete(fileName);
}

The error occurs at: the File.Delete(fileName);

how I can delete or reopen these files after sending the email?

View 9 Replies

How To Recognize Whether The Process Is The IIS Worker Process From Within A .NET Code

Dec 25, 2010

Dear ladies and sirs.

I have a .NET infra code running both within the IIS worker process and within a desktop client app. How can the .NET code determine whether it is running within an IIS worker process?

I know that I could check the name of the process (w3wp.exe, for instance), but I would like a more robust approach. I wish to make a side note. This is not a production need. I need this information to enable certain scenarios useful during the development and testing phase. Specifically to ease the testing of secure vs non secure configurations.

View 3 Replies

C# - Tracking The Process Of A Singleton Process In A Web Application

Jan 26, 2010

When I hit the run button (in my Default.aspx), a process starts (this process contacts a webservice to get some files, etc). How do I: Ensure that only a single process is running at a time (i.e. if I refresh the browser, I don't want to start the process a second time)Track progress - there are 4 points of the process (at 25%, 50%, 75%, 100%) that I want to track, and when each part completes, I want to update the progress bar. I have a status object for the running process, but the question is how to update the progress bar automatically? Do I need to use threads to achieve the above two?

View 1 Replies

Web Forms :: Process Cannot Access The File It Is Being Used By Another Process?

Nov 6, 2010

My code is that I want to create a log file and log it upon a new user browsing the site. However, what i did was I put in a 6 second delay and then used another browser to access the page. And it threw an Exception saying it is being used by another process which is true. So how come I set it so that, if IT is being used by another process, WAIT and retry every 500 milliseconds until it becomes free/available?

here's the code:

protected void Page_Load(object sender, EventArgs e)
{if (!IsPostBack) // if this is the first time page loads, set k to 1
{ lognewuser();
}}

[Code]....

View 1 Replies

The Process Cannot Access The File 'C:inetpub' Because It Is Being Used By Another Process

Mar 28, 2011

I am having the text file which is used to track all the ip address which is available in the network and replace the content from"Reply from 172.29.116.3: bytes=32 time=1ms TTL=255" to 172.29.116.3.

For this task i am having 2 functions 1.runCMD() Function is used to create a file which ping all the ip address between 3 to 254 ("Reply from 172.29.116.3: bytes=32 time=1ms TTL=255").

2.Another function textFileReplace() which is used to replace the text from "Reply from 172.29.116.3: bytes=32 time=1ms TTL=255" to 172.29.116.3.

This process will continue every 30 minutes..

But i am having the error while accessing the function textFileReplace() as The process cannot access the file 'C:inetpub' because it is being used by another process.

View 4 Replies

Web Forms :: Want To Be Change In Regular Interval?

Jan 22, 2010

've using adrotator in my web page store few images using xml file .The problem is only image change when refresh but i want to be change in regular interval.

View 5 Replies

Can Bind The An Interval Of 100 Years With A Dropdownlist

May 27, 2010

How can i bind the an interval of 100 years with a dropdownlist.

To be more precise, I want to bind 1990 to 2010 to a dropdownlist .

View 5 Replies

How To Refresh Update Panel At Certain Interval

Feb 9, 2011

How can i trigger my update panel to refresh after a certain period of time.

View 3 Replies

Web Forms :: How To Switch Between 2 Images With An Interval Of 1 Second

Jan 21, 2011

I wonder how it will be possible to have an imagebutton to switch between Image1.jpg and Image2.jpg with an interval of 1 second. It will loop like this Image1.jpg,Image2.jpg,Image1.jpg all the time.

For example in this case, the images will start switch if the public variable blinkImage is "true".

[Code]....

View 6 Replies

MP3 Uploading With Time Interval Selection?

Sep 9, 2010

I am writing a music related web site. What I am trying to do is have the user upload a song (MP3, MP4, Wav). I then want to be able to slice the song to a max lengh of 30 seconds. The user would be able to select a starting point and I would cut the song down to 30 seconds from that point.

View 1 Replies

Run A Webpage At Particular Interval In Host Server?

Mar 15, 2011

I have one question that is i have to run one program in host server at a particular interval (lets say in each & every 1 hour).

But the thing is that in host server we can't run scheduler , so i want to know is there any approach by which we can achieve this task.

View 6 Replies

Web Forms :: Reduce The Interval Between Two Textbox?

Jul 11, 2010

If you use a space <br /> this is a little too much space.Is it possible to reduce the interval between two textbox?

View 6 Replies

WCF / ASMX :: Fetching Data After Every Fixed Interval?

Oct 18, 2010

I have a webservice which needs to query the Database every hour to get the latest copy of the data. What would be the best way to have the websevice call a method every hour. I am condering using the imers.Interval to call a method every hour.

View 3 Replies

Auto Refresh Webpage After Defined Interval?

Aug 20, 2010

In one of my website, i required to implement automatic refresh of webpage after 15 minute.

For this to achive i have write following line of code <meta http-equiv="refresh" content="60;url=" />

But i am facing one problem that after this duration of 15minute page will refresh as a new page load.

At my page i have used combo box having city list, there is a case when i select an item from this list at index 3. After that i just make page idle and after 15 minute page is refresh with the script i write for auto post back (mentioned above). But the problem is that due to this page is reload as a new page and code inside (!PostBack) execute which refill combobox and reset at index 1. My basic requirement is that whenever user reaches that page and makes it idle for longer time, session should not expire and hence i am writing above script so that session would be live.

View 3 Replies

AJAX :: Display Page Elements After Interval?

Sep 15, 2010

I'd like to display certain elements of my page after an interval. I've tried using the 'UpdatePanel and Script Manager', but it seems to Refresh my page after each interval.

How do I prevent that from happening?

There are 3 parts that I want to display, each after 1.5seconds (Div with large letters "Success" (Will happen after a Page.PostBack), Div that Displays Comparisons, Div that Displays the Sample)

Is there a way to write the code inline, so when the page loads the timer intervals dont reload the page?

View 1 Replies

Web Forms :: Switch Between 2 Pictures In ImageButton With 1 Second Interval?

Mar 26, 2010

For the moment I am using this code to put an image to an ImageButton:

ImageButton1.ImageUrl = "~/Pics/Pic1.bmp";

What I wonder is how it will be possible to let this ImageButton change Picture between "Pic1" and "Pic2" that I also have in this folder with one second interval.

So it will be: "Pic1","Pic2","Pic1","Pic2" and so on...

If this is possible using C#, that would be an interesting solution ?

View 11 Replies

Web Forms :: Update Database Data After Particular Interval?

Dec 30, 2010

we have to upgrade a database application.

In the previous application the transaction is updated 2 days later into the database.

Now we have to update that instantly when the transaction happens.

How this is possible. I want to know why the database update too late

View 4 Replies

Rss Feed Operation Timed Out?

Jan 15, 2010

I am trying to load the digg favorites rss items. But getting error as operation timed out.Please let me know if anyone have solved this issue before.

Public Shared Function HasRssItems() As Boolean
Dim doc As New XmlDocument
doc.Load("http://digg.com/users/Lovelezz/history/favorites.rss")
Return doc.SelectNodes("rss/channel/item").Count > 0
End Function

View 1 Replies

MVC :: How To Create Session Timed Out

Nov 7, 2010

i have two pages a1.aspx a2.aspx....

if i do nothing in a1.aspx for 1minute...it should redirect me to a2.aspx...how to do this in mvc...or javascript

View 6 Replies

Checking If Session Has Timed Out?

Aug 6, 2010

This is my base class for all pages except EndSession.aspx

override protected void OnInit(EventArgs e) {
base.OnInit(e);
if (Context.Session != null)
{
//check the IsNewSession value, this will tell us if the session has been reset.

[Code]....

But on EndSession I try to navigate back to, say default.aspx, and then this code above just redirects be back to EndSession.aspx.

So for better clarification:

Step 1: Go to mypage.aspx
Step 2: Wait for timeout
Step 3: try to navigate away
Step 4: get redirected to EndSession.aspx
Step 5: try to navigate away
Step 6: GoTo set 4
Setp 6 should be actually being able to navigate away...

View 1 Replies

SQL Server :: The Connection Has Timed Out?

Dec 21, 2010

I have deployed my .NET application on IIS and Iam facing the Same Problem " the connection has timed out and the server is taking too long to respond" My OS is Windows XP and IIS 5.1.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved