How to add code of form to windows service?
-
I have one schedule application done with a form having several controls. Now i want to create windowsservice and want to add the task to OnStart() method but what should i add? If you know what I mean? I mean i have form "Form1.cs"with events one different buttons and "schedule.cs" having main method to run the form. Now when i add new item or new project as windows service both have then main methods? Please advice? :confused:
-
I have one schedule application done with a form having several controls. Now i want to create windowsservice and want to add the task to OnStart() method but what should i add? If you know what I mean? I mean i have form "Form1.cs"with events one different buttons and "schedule.cs" having main method to run the form. Now when i add new item or new project as windows service both have then main methods? Please advice? :confused:
A windows service can call other dlls. I would suggest putting the code that is in form1.cs in a new class library. Then add a windows service add a reference to the class library. Then the windows service can call the same code the windows form calls. Ben
-
A windows service can call other dlls. I would suggest putting the code that is in form1.cs in a new class library. Then add a windows service add a reference to the class library. Then the windows service can call the same code the windows form calls. Ben
What you mean ben? Are you saying create a different project or what because class library cannot be added in this project. I tried to create clean class library project and this form1.cs code doesnt fit there because it complains abt different controls. I am now kind of confused a lot :((
-
What you mean ben? Are you saying create a different project or what because class library cannot be added in this project. I tried to create clean class library project and this form1.cs code doesnt fit there because it complains abt different controls. I am now kind of confused a lot :((
That is true, you can not put windows controls in your class library. You should not try to do this anyway. What should go in the class library is the methods that are in the form1.cs that use the data from the windows controls. You should have methods that get called by button click events etc. Then you can add a class library project to your solution and move the code to there. As long as the windows project has a reference to the class library everything should work. Ben
-
That is true, you can not put windows controls in your class library. You should not try to do this anyway. What should go in the class library is the methods that are in the form1.cs that use the data from the windows controls. You should have methods that get called by button click events etc. Then you can add a class library project to your solution and move the code to there. As long as the windows project has a reference to the class library everything should work. Ben
I know that application is same as mine but i dont know how to do registry things.. I mean how to save my data in registry? ok i think i am misleading everybody. Following what i have and what i want to do I have form1.cs which have different events and what i am doing on this form is adding some tasks in ListView. Now the next task is to add scheduling functionality to those tasks. How would you start implementing it? Can somebody please guide me the steps of tasks as how to add schedule functionality? Yes I need a kind of service which will run any tasks which were added in listview in Form1.cs. how would you implement that? Anu guidance please? :confused: