currently I have a windows service that does the following
namespace StockBook.Service
{
    public partial class StockbookService : ServiceBase
    {
        private readonly ElapsedEventHandler Handler = ((sender, e) =>
StartProcessingItems());
        private Timer Timer;

        public StockbookService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            //simple wrappers around IWindsorContainer
            Core.Container.SetCurrent(ServiceContainer.Create());
            Core.Container.Current.Resolve<IStartableServiceBus>
().Start();

            StartProcessingItems();
            SetupProcessingIntervals();
        }

        protected override void OnStop()
        {
            TeardownProcessingIntervals();
            Core.Container.Current.Dispose();
        }

        private void SetupProcessingIntervals()
        {
            Timer = new Timer(TimeSpan.FromHours(4).TotalMilliseconds)
{AutoReset=true};
            Timer.Elapsed += Handler;
        }

        private void TeardownProcessingIntervals()
        {
            Timer.Elapsed -= Handler;
            Timer.Dispose();
        }

        private static void StartProcessingItems()
        {
            var bus = Core.Container.Current.Resolve<IServiceBus>();
            bus.Send(new StartCalculatingAvailabilityOfAllItems { Date
= DateTime.Today });
        }
    }
}

but this seems like too much work for one object, especially one that
cannot be easily tested.
rather than do all this work in the service, could I initialize the
container outside the service (Program.Main?) and inject direct
dependencies into the windows service? If so how would I manage the
disposal of IWindsor?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to