방법: 버퍼링된 그래픽 수동 관리

고급 이중 버퍼링 시나리오의 경우 .NET Framework 클래스를 사용하여 고유한 이중 버퍼링 논리를 구현할 수 있습니다. 개별 그래픽 버퍼를 할당하고 관리하는 클래스는 BufferedGraphicsContext 클래스입니다. 모든 애플리케이션에는 해당 애플리케이션에 대한 모든 기본 이중 버퍼링을 관리하는 자체 기본 BufferedGraphicsContext가 있습니다. Current를 호출하여 이 인스턴스에 대한 참조를 검색할 수 있습니다.

기본 BufferedGraphicsContext에 대한 참조를 가져오려면 다음을 수행합니다.

  • 다음 코드 예제와 같이 Current 속성을 설정합니다.

    BufferedGraphicsContext myContext;
    myContext = BufferedGraphicsManager.Current;
    
    Dim myContext As BufferedGraphicsContext
    myContext = BufferedGraphicsManager.Current
    
    

    참고

    BufferedGraphicsManager 클래스에서 수신하는 BufferedGraphicsContext 참조에서 Dispose 메서드를 호출할 필요가 없습니다. BufferedGraphicsManager는 기본 BufferedGraphicsContext 인스턴스에 대한 모든 메모리 할당 및 배포를 처리합니다.

    애니메이션과 같이 그래픽 집약적인 애플리케이션의 경우 때때로 BufferedGraphicsManager에서 제공하는 BufferedGraphicsContext 대신 전용 BufferedGraphicsContext를 사용하여 성능을 향상시킬 수 있습니다. 이렇게 하면 애플리케이션에서 사용하는 메모리가 더 커지더라도 애플리케이션과 연결된 다른 모든 버퍼링된 그래픽을 관리하는 성능 오버헤드를 발생시키지 않고 그래픽 버퍼를 개별적으로 만들고 관리할 수 있습니다.

전용 BufferedGraphicsContext를 만들려면 다음을 수행합니다.

  • 다음 코드 예제와 같이 BufferedGraphicsContext 클래스의 새 인스턴스를 선언하고 만듭니다.

    BufferedGraphicsContext myContext;
    myContext = new BufferedGraphicsContext();
    // Insert code to create graphics here.
    // On a non-default BufferedGraphicsContext instance, you should always
    // call Dispose when finished.
    myContext.Dispose();
    
    Dim myContext As BufferedGraphicsContext
    myContext = New BufferedGraphicsContext
    ' Insert code to create graphics here.
    ' On a nondefault BufferedGraphicsContext instance, you should always 
    ' call Dispose when finished.
    myContext.Dispose()
    
    

참고 항목