public async void Initialize() { this.Uri = String.Format("file://{0}Resources\\index.html", AppDomain.CurrentDomain.BaseDirectory); this.MapHost = new MapHostTripDetail() { PageViewModel = this }; PhotographicImage image = new PhotographicImage(); await Task.Run(() => { this.TripID = getTripID(); GraphEcologs = GraphEcolog.ExtractGraphEcolog(this.TripID, this.SemanticLink); }); this.SliderMaximum = this.GraphEcologs.Count - 1; this.CurrentIndex = 0; this.CurrentEcolog = this.GraphEcologs[0]; getImage(); DisplayedGraphEcologs = new List <GraphEcolog>(); for (int i = 0; i < GraphIndexLength; i++) { if (i > GraphEcologs.Count - 1) { break; } DisplayedGraphEcologs.Add(GraphEcologs[i]); } }
// コールバック関数:スレッド終了後の処理を記述 private void CallbackMethod(IAsyncResult ar) { // AsyncResultに変換 AsyncResult asyncResult = ar as AsyncResult; // 非同期の呼び出しが行われたデリゲート オブジェクトを取得 ImageDelegate imageDelegate = asyncResult.AsyncDelegate as ImageDelegate; BitmapImage image = PhotographicImage.ByteToImageSource(imageDelegate.EndInvoke(ar).ImageSource); if (image == null) { image = new BitmapImage( new Uri(String.Format("file://{0}Resources\\NoImage.png", AppDomain.CurrentDomain.BaseDirectory))); image.Freeze(); CurrentImage = image; } else { CurrentImage = image; } }
// 非同期させたい(重たい)処理 private PhotographicImage DelegatingMethod(int tripID, DateTime jst) { return(PhotographicImage.CreatePhotographicImage(this.TripID, this.CurrentEcolog.Jst)); }