ABOUT ME

Today
Yesterday
Total
  • Downloader 객체
    Silverlight 2008. 1. 22. 10:11

    Downloader 객체에 대한 설명 (MSDN 참조)

    Silverlight에는 외부 리소스에 접근해서 현재 어플리케이션으로 받아오는 방법이 2가지가 있다.

    첫번 째는 이번에 설명할 Downloader를 이용하는 방법이고

    두번 째는 HttpWebRequest를 사용하는 방법이다.


    우선 MSDN에 나와있는 Downloader의 간단한 설명을 보자
    Represents the set of download functionality for a Silverlight plug-in. The downloader can asynchronously download content that can be obtained through an HTTP GET request.
    빨간줄을 자세히 살펴보면 "Downloader 객체는 HTTP GET 방식을 사용하고 Sync가 아닌 ASync를 지원."

    즉 내부적으로 HttpWebRequest를 사용할 것으로 보인다.

    그리고 현재는 Sync가 아닌 ASync만 가능한 것으로 보인다.

    Sync를 사용하려면 HttpWebRequest를 사용해야 하며, Download progress 등의 이벤트는 사용하지 못한다.


    이제 다음 문장을 보자.
    The Downloader cannot be used to download files across domains (content that is not from the site of origin for the hosting HTML page).
    이 문장에서는 across domain이 불가능하다는 것을 보여준다.

    즉, 자기 도메인안에 있는 정보만 다운로드가 가능하다.


    마지막으로 퍼포먼스에 대한 언급이 있다.
    Performance Tip: When using the Downloader object, after the Completed event fires, detach all event handlers from the Downloader and then set Downloader to null.
    간단히 해석하자면, Completed 이벤트가 발생했을때 현재 사용된 Downloader 객체의 모든 이벤트 핸들러를 제거하고, Downloader를 null로 초기화 하라는 문장이다.


    아마도 저렇게 해주지 않으면 가비지 컬렉터에서 걸러내지 못하는 현상이 발생하는가 보다.
    ( 이건 단지 예상이다 -_- )


Designed by Tistory.