PDA

View Full Version : عدم اجرای برنامه برای بار دوم



hassan_kahrizy
چهارشنبه 07 اردیبهشت 1384, 10:57 صبح
هو العلیم
سلام به تمامی دوستان
سوالی داشتم چطور می شه ارنامه ای نوشت که فقط یک بار اجرا بشه
یعنی اگر بار دوم اجرا شد پیغتم بده
در ضمن چطور می شه برنامه رو در start upویندوز قرار داد یعنی بعد از بوت شدن خوذکار اجرا بشه

با تشکر

M.GhanaatPisheh
چهارشنبه 07 اردیبهشت 1384, 12:37 عصر
باید از singleton pattern استفاده کنید.

یاشار
چهارشنبه 07 اردیبهشت 1384, 13:16 عصر
یک راه ناشیانه‌تر ولی ساده (http://www.codeproject.com/vb/net/ActivateSingleAppInstance.asp)

hassan_kahrizy
پنج شنبه 08 اردیبهشت 1384, 02:04 صبح
هو العلیم
با سلام خدمت شما دوستان وتشکر



باید از singleton pattern استفاده کنید.

می شه بیشتر توضیح بدبد
ممنون می شم

M.GhanaatPisheh
جمعه 09 اردیبهشت 1384, 01:07 صبح
Consider the following example:
You are building a quote application, which contains a class that is responsible
for managing all of the quotes in the system. It is important that all quotes interact
with one and only one instance of this class. How do you structure your
design so that only one instance of this class is accessible within the application?
A simple solution to this problem is to create a QuoteManager class with a private
constructor so that no other class can instantiate it. This class contains a static instance
of QuoteManager that is returned with a static method named GetInstance(). The
code looks something like this:


public class QuoteManager
{
//NOTE: For single threaded applications only
private static QuoteManager _Instance = null;
private QuoteManager() {}
public static QuoteManager GetInstance()
{
if (_Instance==null)
{
_Instance = new QuoteManager ();
}
return _Instance;
}
//... functions provided by QuoteManager
}



It is likely that you have solved problems like this in a similar manner, as many other
developers have. In fact, pattern writers on the lookout for recurring problems and
solutions have observed this kind of implementation frequently, distilled the common
solution, and documented the problem-solution pair as the Singleton pattern
[Gamma95].

ایده رو متوجه شدید دوست عزیز؟
موفق باشید.

hassan_kahrizy
جمعه 09 اردیبهشت 1384, 01:53 صبح
هوالعلیم
با سلام
خیلی ممنون
متشکرم
عالی بود :flower: :flower: