|
your OnStart() needs to set the "hey i'm started flag" and then continue doing something until told to stop or pause by the OnStop() or OnPause()
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
|
|
|
|
|
Hi,
Thanks Ahmed for the reply.
Then I have two questions 1. how can I write on to a console application and then 2. how should I call stop method from start method
Means how can I control start and stop methods in Wnidows service or how can I make my windows service to execute for each 10 minutes.
Any link or any example would help please. Thanks in advance.
Thanks & Regards,
Mohammad Abdul Aleem
St Louis MO
|
|
|
|
|
there are many examples on codeproject of windows services. I suggest you type "windows service" in the above search box and do some reading...
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
|
|
|
|
|
Hi Ahmed,
I have searched all of them but no where I found to start my service and stop it till I say stop. I couldnt find this example. And is there any way that I can write the out put of the windows service in to console or file or on messagebox. I need this help.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
My suspicion here is that you've hit a permissions issue. Looking at your code, you've attempted to create an event source - if I'm right, your service does not have the permissions to manipulate the event log. Change the event source to write to Application instead.
|
|
|
|
|
Hi Pete,
Can you please help me and eloborate little bit, I am not getting any idea about I have been searching for it. How should I write to application instead of on the EvenLog. Any links or any sort of help would help me. Thanks in advance Pete.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
He meant write the to the Application Event Log, look at your event viewer.
Honestly it seems you need much more help than is possible here. Perhaps take a class at a local community college.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
Its writing some thing in even log, but I am not much familiar with writing in the event log. Its writing the following
The description for Event ID 0 from source CalculatorWindowsService cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Service cannot be started. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
at System.Console.ReadKey(Boolean intercept)
at System.Console.ReadKey()
at CalculatorWindowsServiceAppl.CalculatorWindowsService.OnStart(String[] args) in D:\StatusMessage\CalculatorWindowsServiceAppl\CalculatorWindowsServiceAppl\CalculatorWindowsService.cs:line 26
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
The problem here is that you're trying to read from / write to the Console within a Service.
This is NOT possible.
Write to a file instead.
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
|
|
|
|
|
Yes it has resloved the problem. Thanks all of you.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Hi mates,
I have one textbox and one button. How can I use javascript not to trigger the buttons click event when the
enter key is pressed inside textbox?
<asp:TextBox ID="txtSearch" runat="server" AutoPostBack="true"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClientClick="window.open'TKSRCH.aspx','search','width=900,height=500,left=400,top=350,toolbar=0,status=0,resizable=0,')"/>
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
function onKeyPress()
{
return event.keyCode == '13' ? false : true;
}
<asp:TextBox ID="txtSearch" runat="server" AutoPostBack="true" onkeypress="onKeyPress()"></asp:TextBox>
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
thanks for you quick reply.
when i press button, a pop up window will show.
when i enter key in textbox, a pop up will not show.
how to put that code in here
return event.keyCode == '13' ? false : true;
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
modified on Sunday, January 23, 2011 9:24 PM
|
|
|
|
|
Just put it in your OnKeyPress() method. (I'll leave it to you to figure out where)...
if( event.keyCode == '13' ){ return false; }
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hi
I need to send a large number of emails as newsletter in website using SMTP protocol. The barrier is the server runs out of memory and raises an exception when emails count is large. I use a loop that iterates through an array of emails and send them. Is there any method that can mitigate this constriction. emails count is more than 100000.
|
|
|
|
|
If you are working for a website with 100,000+ subscriptions to a newsletter, you probably work for a website that should have it's own smtp system setup to deal with this. If it doesn't, I'm a little concerned that this "newsletter" you speak of is really more of a "spamletter"...
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
If the server is running out of memory than there isn't much you can do. Even if you dispose of the objects the GC is non-deterministic so it may not free any memory in time to prevent the problems. You could try multi-threading but it would still face the same memory constraint. Another options if available is to use two, or more, SMTP servers. Sending this many emails at once would be better handled by a bulk email service.
Also sending out that many emails at once you are risking your domain being blacklisted as a spammer.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Is there a way to make sending emails slower ? For example make it take 1 hour or more to send emails to alleviate the burden. Asynchronous or some sort of that technique .
|
|
|
|
|
You can always create a service the will send so many emails per hour. You are in complete control of the code.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I know , I wanna ask "is it helpful to invoke Sleep(milliSeconds) function in the body of the loop to mitigate this problem ? " Or another technique should be used ? for example creating threads or invoking functions asynchronously ?
|
|
|
|
|
Never, ever use Sleep to block processing for a period in time. It's a poor design choice.
|
|
|
|
|
Can you give me a pragmatic way to send emails slowly to compensate for lack of server resources ?
|
|
|
|
|
If you need to send that many emails, you need to run the application on a separate server (actually it should be from several servers). Never attempt to use the web server to do this because you will always be competing with HTTP traffic (plus, it's a good idea to have the SMTP protocol on a different server to the one running the HTTP protocol. Try to keep your resources separated out for security purposes).
|
|
|
|
|
For some reasons we need to countenance our current server configuration with limited resources.
So we don't expect ideal. The delay is not a problem even if it takes 3 hours to send them. We can run the send operation when the site traffic is on the wane.(e.g. 3 AM) What do you think then ?
Thanks Regards
|
|
|
|
|
I just asked for a solution matching my current configuration ?
|
|
|
|