المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : object instance shared across entire application



C# Programming
06-18-2009, 06:20 PM
I am writing a Windows.Forms application and I have a some objects that I want to be Global. Example of these objects are an object for maintaining a collection of remote resources, and a "Task list" type object that shows all running tasks. There is only ever 1 instance of these objects, they are created when the application starts and are destroyed when the application ends.

I use these objects throughout my application and inorder to do so I have to pass an "Environment" object to each form, this Environment object serves as a pointer to the global objects.

This seems very kludgy, is there a way that you can have global objects shared across the application without having to pass them to each form/thread you create?

Thanks in advance!