TimeZoneInfo.ClearCachedData 메서드

정의

캐시된 표준 시간대 데이터를 지웁니다.

public:
 static void ClearCachedData();
public static void ClearCachedData ();
static member ClearCachedData : unit -> unit
Public Shared Sub ClearCachedData ()

설명

캐시된 표준 시간대 데이터에는 현지 표준 시간대 및 UTC(협정 세계시) 영역에 대한 데이터가 포함됩니다.

호출할 수 있습니다는 ClearCachedData 표준 시간대 정보 또는 로컬 시스템의 표준 시간대가 변경 했다는 사실을 반영 하도록 애플리케이션의 캐시에 사용 되는 메모리를 줄이는 방법.

로컬 및 UTC 표준 시간대에 대한 참조를 저장하는 것은 권장되지 않습니다. 메서드를 ClearCachedData 호출한 후 이러한 개체 변수는 더 이상 참조되거나 TimeZoneInfo.Utc참조 TimeZoneInfo.Local 되지 않는 정의 TimeZoneInfo 되지 않은 개체가 됩니다. 예를 들어 다음 코드에서 메서드에 대한 TimeZoneInfo.ConvertTime(DateTime, TimeZoneInfo, TimeZoneInfo) 두 번째 호출은 변수가 더 이상 같TimeZoneInfo.Local음으로 간주되지 않으므로 throw ArgumentException local 합니다.

TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
TimeZoneInfo local = TimeZoneInfo.Local;
Console.WriteLine(TimeZoneInfo.ConvertTime(DateTime.Now, local, cst));

TimeZoneInfo.ClearCachedData();
try
{
   Console.WriteLine(TimeZoneInfo.ConvertTime(DateTime.Now, local, cst));
}
catch (ArgumentException e)
{
   Console.WriteLine(e.GetType().Name + "\n   " + e.Message);
}
open System

let cst = TimeZoneInfo.FindSystemTimeZoneById "Central Standard Time"
let local = TimeZoneInfo.Local
printfn $"{TimeZoneInfo.ConvertTime(DateTime.Now, local, cst)}"

TimeZoneInfo.ClearCachedData()
try
   printfn $"{TimeZoneInfo.ConvertTime(DateTime.Now, local, cst)}"
with :? ArgumentException as e ->
   printfn $"{e.GetType().Name}\n   {e.Message}"
Dim cst As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")
Dim local As TimeZoneInfo = TimeZoneInfo.Local
Console.WriteLine(TimeZoneInfo.ConvertTime(Date.Now, local, cst))

TimeZoneInfo.ClearCachedData()
Try
   Console.WriteLine(TimeZoneInfo.ConvertTime(Date.Now, local, cst))
Catch e As ArgumentException
   Console.WriteLine(e.GetType().Name & vbCrLf & "   " & e.Message)
End Try

적용 대상