|
Only use Thread.Sleep will not solve the problem because this thread doesn't react on service requests and at least it should react on stop request.
Greetings
Covean
|
|
|
|
|
<DevilsAdvocate>The OnStart could spawn off a Thread that Sleeps and the OnStop could Abort that Thread.</DevilsAdvocate>
|
|
|
|
|
Oh yes I also think its a very good habit to abort your threads!
Greetings
Covean
|
|
|
|
|
Sleeping for 86400000 milliseconds is not a good idea.
|
|
|
|
|
You are right...
Thread.Sleep is not a good thing to use. I just gave an alternate solution as the person dont wants to use an already existing scheduler service...
If he is smart, he should also able to point this himself.... .
|
|
|
|
|
You'd prolly want a service, so that you won't have to log in to the machine. Then again, a service that keeps polling the time to do an action once a day would be wasting a lot of resources. Still, it's an easy solution, and makes for easy maintenance - and an interval of a minute wouldn't waste that much.
There's an article here on writing your own application-scheduler as a Windows-service.
Good luck
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: You'd prolly want a service, so that you won't have to log in to the machine.
You don't have to log in to the machine for a scheduled task either. I agree with the other posters: I don't really understand why this has to run as a service rather than a scheduled task. But if that is what the OP wants, it can be done.
|
|
|
|
|
David Skelly wrote: You don't have to log in to the machine for a scheduled task either.
Cool, you're right! The scheduler is already a service, hence it is already running.
The logon-problem shot in my mind as an argument for wanting a service over a console-application. I was guessing why the OP didn't want to use a console, whilst I could simply ask "why not?"
David Skelly wrote: But if that is what the OP wants, it can be done.
Knowing what you want can be quite difficult
--edit--
the +5 is for teaching me something new
I are Troll
|
|
|
|
|
Dear all,
Thanks a lot for usefull responses.
Im very new in this and i thought that a windows service is the solution for my project.
My application had to import some data from network once a day, save it to our db and export it to some other relations.
Bud i will discuse your suggestions with my coworkers.
Thanks a lot.
|
|
|
|
|
I would definitely look into the Task Scheduler for that, because it gives you much more flexibility in terms of when the task runs. It also gives you the ability to view when the task last ran, etc. Your importer application would be a straightforward console application that gets invoked when required by the scheduler. Easier for testing, as well, because that way you can run the import from the command line whenever you want to test it without having to fiddle around with the settings on a service.
If you do decide to go down the service route, all you need is a timer that fires off at fixed intervals (e.g. once a minute) to check the time to decide when to run your import. Unfortunately the VB.NET Timer class does not allow you to schedule an event for a particular time (that has always seems to me to be a bit of an obvious oversight but I guess that takes us back to the Task Scheduler). If you use Thread.Sleep on the main thread of your service be aware that will block the thread and you will not be able to shut it down unless it wakes up occasionally to check for a stop request.
|
|
|
|
|
A Windows Service is a worst choice for your requirement. If you had spelled out your requirements in the original post, you'd have got better answers earlier.
I have an application that does exactly this:
1. The data comes as a text file feed.
2. An SSIS package (SQL Server Integration Services) loads the contents of this file to the database. It is first loaded "as is" in a staging database. Then the SSIS package executes a stored procedure that reads the staging database, does all the required transformations, calculations, etc. and loads the transformed data into the actual application database.
3. An SQL Server job executes the package at a specified time once a day, typically at midnight since no one will be using the database at that time.
Try something on these lines.
|
|
|
|
|
Priya Prk wrote: import some data
If you are using SQL Server you may be able to use the bcp utility. In which case, you need only write a format file and a command file. If you need help with that, you can ask questions in the database forum.
Other databases may also have import utilities.
|
|
|
|
|
There are two applications, one is 64 bit and another one is 32 bit
1, I need to use 64 bit app to launch 32 bit one, how to implement it?
2, Is it possible to access the functions in 32 bit app from 64 bit
Thanks you in advance
|
|
|
|
|
jsjwql123 wrote: 1, I need to use 64 bit app to launch 32 bit one, how to implement it?
Look at the Process.Start() method.
jsjwql123 wrote: 2, Is it possible to access the functions in 32 bit app from 64 bit
No, you cannot mix 32-bit and 64-bit code in the same process.
|
|
|
|
|
He is already asking for two process. So, it is possible, but you must use some kind of RPC/Remoting.
|
|
|
|
|
Paulo Zemek wrote: but you must use some kind of RPC/Remoting.
That would mean 2 seperate processes.
|
|
|
|
|
Hi all,
I am a newbie to the C# applications,I have a combobox in my application where i need to display the tooltip for the items inside it when mouse is moved over the items.
I tried with the fucntions "m_cbCommPort_MouseHover" and "m_cbCommPort_DropDown", but both did not work fine.Please suggest me a good solution for this.
Thanks in advance.
|
|
|
|
|
I have been trying to change an entry in a combo box for a while now and have got the text to change but when i click out of do something else it hasnt actually changed the entries value in the list.
case (char)Keys.Enter:
comboBox1.Text.Remove(0, comboBox1.Text.Length);
imageViewer1.RenameShape("test");
comboBox1.SelectedText = "test";
comboBox1.Refresh();
break;
Above is my current attempt which changes the text but does not store this change.
So my shape renames but the shapes name in the combo box does not.
Cant help feeling i need to do more than :
comboBox1.SelectedText = "test";
thanx in advance
|
|
|
|
|
Have you tried setting the selected index ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have tried this but cannot find a way of getting it to work for me :
I dont know how to set the selected index's text property
|
|
|
|
|
Set the Text property, not the SelectedText . SelectedText is the string within the displayed text that is currently highlighted for cut/copy/paste actions. Setting the Text property will automatically select the correct item in the combo box if it is present. There is also no need to call Refresh .
|
|
|
|
|
Thanx have tried this and the text does change but when i drop down the list test is not there.
case (char)Keys.Enter:
comboBox1.Text.Remove(0, comboBox1.Text.Length);
imageViewer1.RenameShape("test");
comboBox1.Text = "test";
break;
It just displays shape1 , shape2 .........
|
|
|
|
|
Use this:
ComboBox1.Items.Add("test");
ComboBox1.SelectedIndex = ComboBox1.Items.Count-1;
|
|
|
|
|
I think your problem is that you want to change the value of an entry by typing over it. The problem being that once you start typing you loose any reference to the item you want to change. Perhaps an option would be to handle to OnEnter event and store the selected index, then when you detect the 'Enter' key you can use that index to change the value of the correct item.
something like...
int currentIndex = -1;
void OnEnter(object sender, EventArgs e)
{
currentIndex = comboBox1.SelectedIndex;
}
void KeyDown(object sender, KeyDownEventArgs e)
{
case (char)Keys.Enter:
imageViewer1.RenameShape("test");
comboBox1.Items[currentIndex] = comboBox1.Text;
comboBox1.Text = "";
break;
}
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thank you for all of the replies.
I got everything working now there was alot to it as the shapes can be selected by the mouse too so this also had to change the comboBox :
void imageViewer1_Clicked(object sender, EventArgs e)
{
if (imageViewer1.ListOfShapes.Count > 0)
{
for (int i = 0; i < comboBox1.Items.Count; i++)
{
if ((string)comboBox1.Items[i] == imageViewer1.ListOfShapes[imageViewer1.SelectedShapeIndex].Name)
{
comboBox1.SelectedIndex = i;
m_comboBoxCurrentIndex = i;
}
}
}
}
Above and below (solution) may not be pretty but it works
case (char)Keys.Enter:
if (comboBox1.SelectedIndex != -1)
{
m_comboBoxCurrentIndex = comboBox1.SelectedIndex;
comboBox1.Text.Remove(0, comboBox1.Text.Length);
imageViewer1.RenameShape("test");
comboBox1.Items[m_comboBoxCurrentIndex] = "test";
comboBox1.Text = "";
}
Thanx George
|
|
|
|