Click here to Skip to main content
15,904,823 members
Home / Discussions / C#
   

C#

 
GeneralRe: lock and Monitor.TryEnter Pin
koleraba21-Jun-08 12:59
koleraba21-Jun-08 12:59 
GeneralRe: lock and Monitor.TryEnter Pin
Scott Dorman21-Jun-08 13:52
professionalScott Dorman21-Jun-08 13:52 
GeneralRe: lock and Monitor.TryEnter Pin
koleraba22-Jun-08 14:34
koleraba22-Jun-08 14:34 
QuestionCan't override the mathod OnKeyPress of TextBox control ( attached code ) Pin
Yanshof21-Jun-08 6:14
Yanshof21-Jun-08 6:14 
AnswerRe: Can't override the mathod OnKeyPress of TextBox control ( attached code ) Pin
Luc Pattyn21-Jun-08 7:00
sitebuilderLuc Pattyn21-Jun-08 7:00 
AnswerRe: Can't override the mathod OnKeyPress of TextBox control ( attached code ) Pin
MagProWin21-Jun-08 7:56
MagProWin21-Jun-08 7:56 
GeneralRe: Can't override the mathod OnKeyPress of TextBox control ( attached code ) Pin
Guffa22-Jun-08 2:57
Guffa22-Jun-08 2:57 
QuestionWindow Service problem Pin
Yulianto.21-Jun-08 5:03
Yulianto.21-Jun-08 5:03 
I have the following code. I've install the service, and start it. I want to create a file 'c:\test.txt' using the timer. But the file still can't be created. I've check for Application error at windows 'event viewer', but have not find any.

using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.IO;

namespace WindowsService
{
    class WindowsService : ServiceBase
    {
        private System.Windows.Forms.Timer timer1;
        private System.ComponentModel.IContainer components;

        public WindowsService()
        {
            this.ServiceName = "G-ERP Auto backup";
            this.EventLog.Source = "G-ERP Auto backup";
            this.EventLog.Log = "Application";
            
            this.CanHandlePowerEvent = true;
            this.CanHandleSessionChangeEvent = true;
            this.CanPauseAndContinue = true;
            this.CanShutdown = true;
            this.CanStop = true;

            InitializeComponent();

            if (!EventLog.SourceExists("G-ERP Auto backup"))
                EventLog.CreateEventSource("G-ERP Auto backup", "Application");
        }

        static void Main()
        {
            ServiceBase.Run(new WindowsService());
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        protected override void OnStart(string[] args)
        {
            this.timer1.Enabled = true;
            base.OnStart(args);
        }

        protected override void OnStop()
        {
            this.timer1.Enabled = false;
            base.OnStop();
        }

        protected override void OnPause()
        {
            this.timer1.Enabled = false;
            base.OnPause();
        }

        protected override void OnContinue()
        {
            this.timer1.Enabled = true;
            base.OnContinue();
        }

        protected override void OnShutdown()
        {
            base.OnShutdown();
        }

        protected override void OnCustomCommand(int command)
        {

            base.OnCustomCommand(command);
        }

        protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)
        {
            return base.OnPowerEvent(powerStatus);
        }

        protected override void OnSessionChange(SessionChangeDescription changeDescription)
        {
            base.OnSessionChange(changeDescription);
        }

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            // 
            // timer1
            // 
            this.timer1.Enabled = true;
            this.timer1.Interval = 1000;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            File.Copy(@"c:\YServer.txt", @"c:\test.txt"); 
            if (!File.Exists(@"c:\YServer.txt"))
            {
                File.Copy(@"c:\YServer.txt", @"c:\test.txt");
            }
        }
    }
}



<italic>Work hard, Work effectively.
Stock Pick | Small Website Host

AnswerRe: Window Service problem Pin
Ashfield21-Jun-08 7:32
Ashfield21-Jun-08 7:32 
GeneralRe: Window Service problem Pin
Yulianto.22-Jun-08 15:24
Yulianto.22-Jun-08 15:24 
QuestionSending keys to the active windows - almost there Pin
Dirso21-Jun-08 5:00
Dirso21-Jun-08 5:00 
AnswerRe: Sending keys to the active windows - almost there Pin
mav.northwind22-Jun-08 19:01
mav.northwind22-Jun-08 19:01 
GeneralRe: Sending keys to the active windows - almost there Pin
Dirso23-Jun-08 13:38
Dirso23-Jun-08 13:38 
GeneralRe: Sending keys to the active windows - almost there Pin
mav.northwind25-Jun-08 9:25
mav.northwind25-Jun-08 9:25 
GeneralRe: Sending keys to the active windows - almost there Pin
Dirso25-Jun-08 10:39
Dirso25-Jun-08 10:39 
GeneralRe: Sending keys to the active windows - almost there Pin
mav.northwind25-Jun-08 19:17
mav.northwind25-Jun-08 19:17 
GeneralRe: Sending keys to the active windows - almost there Pin
Dirso26-Jun-08 0:50
Dirso26-Jun-08 0:50 
QuestionToolStripItem visible problem Pin
Yulianto.21-Jun-08 4:56
Yulianto.21-Jun-08 4:56 
AnswerRe: ToolStripItem visible problem Pin
subai21-Jun-08 20:26
subai21-Jun-08 20:26 
QuestionAbstract classes hierarchy Pin
Metal7621-Jun-08 4:55
Metal7621-Jun-08 4:55 
AnswerRe: Abstract classes hierarchy Pin
User 665821-Jun-08 5:23
User 665821-Jun-08 5:23 
GeneralRe: Abstract classes hierarchy Pin
Metal7621-Jun-08 5:32
Metal7621-Jun-08 5:32 
GeneralRe: Abstract classes hierarchy Pin
User 665821-Jun-08 5:39
User 665821-Jun-08 5:39 
GeneralRe: Abstract classes hierarchy Pin
Mark Churchill21-Jun-08 22:02
Mark Churchill21-Jun-08 22:02 
AnswerRe: Abstract classes hierarchy Pin
Guffa21-Jun-08 5:45
Guffa21-Jun-08 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.