Statische Liste Multithread -AnwendungC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Statische Liste Multithread -Anwendung

Post by Anonymous »

Code: Select all

public class Helper
{
private static List timeZoneList = null;

public static List GetTimeZoneList()
{
if (timeZoneList == null)
{
timeZoneList = new List();
timeZoneList.Add(new TimeZoneMap() { Id = "Dateline Standard Time", DisplayName = "(UTC-12:00) International Date Line West" });
timeZoneList.Add(new TimeZoneMap() { Id = "UTC-11", DisplayName = "(UTC-11:00) Coordinated Universal Time-11" });
timeZoneList.Add(new TimeZoneMap() { Id = "Aleutian Standard Time", DisplayName = "(UTC-10:00) Aleutian Islands" });
}
}
Die TimeZonelist wird in einer Instanzklasse initialisiert (Helfer), aber es ist eine statische Liste. Dies geschieht nur für 2 bis 3 zufällige Instanz aus den 200. < /p>
Was machen wir hier falsch? ? Zweifeln Sie jedoch immer noch, dass dies die Liste nur lesen würde. Was für die erste Last bekommen wir nur 5 anstelle von allen!?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post