Page.RegisterAsyncTask メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Page.RegisterAsyncTask メソッドの意味・解説 

Page.RegisterAsyncTask メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

新し非同期操作ページ登録します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub RegisterAsyncTask ( _
    task As PageAsyncTask _
)
Dim instance As Page
Dim task As PageAsyncTask

instance.RegisterAsyncTask(task)
public void RegisterAsyncTask (
    PageAsyncTask task
)
public:
void RegisterAsyncTask (
    PageAsyncTask^ task
)
public void RegisterAsyncTask (
    PageAsyncTask task
)
public function RegisterAsyncTask (
    task : PageAsyncTask
)

パラメータ

task

非同期操作定義する PageAsyncTask。

例外例外
例外種類条件

ArgumentNullException

非同期操作null 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

ExecuteRegisteredAsyncTasks メソッドRegisterAsyncTask メソッドでの AsyncTimeout プロパティ使用方法次のコード例示します開始ハンドラ終了ハンドラ、およびタイムアウト ハンドラ使用方法注意してください。この例では非同期操作状況説明するために、AsyncTimeout プロパティ指定して操作割り当てた時間超えるように、人為的に遅延させています。実際の状況では、データベース コールまたはイメージ生成などを実行するために非同期操作使用できますその場タイムアウト ハンドラ使用することで、操作実行指定時間内に完了しない場合に、性能低下させて機能維持 (グレースフル デグラデーション) が行われます

<%@ Page Language="VB" AsyncTimeout="2"%>

<script runat="server">

  Protected Sub Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)
    
    ' Define the asynchronuous task.
    Dim mytask As New Samples.AspNet.VB.Controls.MyAsyncTask()
    Dim asynctask As New
 PageAsyncTask(AddressOf mytask.OnBegin, AddressOf
 mytask.OnEnd, AddressOf mytask.OnTimeout, DBNull.Value)

    ' Register the asynchronous task.
    Page.RegisterAsyncTask(asynctask)
      
    ' Execute the register asynchronous task.
    Page.ExecuteRegisteredAsyncTasks()

    TaskMessage.InnerHtml = mytask.GetAsyncTaskProgress()
    
  End Sub
</script>

<html  >
<head runat="server">
    <title>Asynchronous Task Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <span id="TaskMessage" runat=server>
      </span>
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" AsyncTimeout="2"%>

<script runat="server">

  protected void Page_Load(object sender, EventArgs
 e)
  {
    // Define the asynchronuous task.
    Samples.AspNet.CS.Controls.MyAsyncTask mytask =    
      new Samples.AspNet.CS.Controls.MyAsyncTask();
    PageAsyncTask asynctask = new PageAsyncTask(mytask.OnBegin,
 mytask.OnEnd, mytask.OnTimeout, null);

    // Register the asynchronous task.
    Page.RegisterAsyncTask(asynctask);
      
    // Execute the register asynchronous task.
    Page.ExecuteRegisteredAsyncTasks();

    TaskMessage.InnerHtml = mytask.GetAsyncTaskProgress();

  }
</script>

<html  >
<head runat="server">
    <title>Asynchronous Task Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <span id="TaskMessage" runat=server>
      </span>
    </div>
    </form>
</body>
</html>
Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Threading

Namespace Samples.AspNet.VB.Controls

    Public Class MyAsyncTask

        Private _taskprogress As String
        Private _dlgt As AsyncTaskDelegate

        ' Create delegate.
        Delegate Function AsyncTaskDelegate()

        Public Function GetAsyncTaskProgress()
 As String
            Return _taskprogress
        End Function

        Public Function DoTheAsyncTask()

            ' Introduce an artificial delay to simulate a delayed 
            ' asynchronous task. Make this greater than the 
            ' AsyncTimeout property.
            Thread.Sleep(TimeSpan.FromSeconds(5.0))

        End Function


        ' Define the method that will get called to
        ' start the asynchronous task.
        Public Function OnBegin(ByVal
 sender As Object, ByVal
 e As EventArgs, ByVal cb As AsyncCallback, ByVal extraData As Object)
 As IAsyncResult

            _taskprogress = "Beginning async task."

            Dim _dlgt As New
 AsyncTaskDelegate(AddressOf DoTheAsyncTask)
            Dim result As IAsyncResult = _dlgt.BeginInvoke(cb,
 extraData)
            Return result

        End Function 'OnBegin

        ' Define the method that will get called when
        ' the asynchronous task is ended.
        Public Sub OnEnd(ByVal
 ar As IAsyncResult)

            _taskprogress = "Asynchronous task completed."
            _dlgt.EndInvoke(ar)

        End Sub

        ' Define the method that will get called if the task
        ' is not completed within the asynchronous timeout interval.
        Public Sub OnTimeout(ByVal
 ar As IAsyncResult)

            _taskprogress = "Ansynchronous task failed to complete
 because " & _
            "it exceeded the AsyncTimeout parameter."

        End Sub

    End Class

End Namespace

using System;
using System.Web;
using System.Web.UI;
using System.Threading;

namespace Samples.AspNet.CS.Controls
{
    public class MyAsyncTask
    {
        private String _taskprogress;
        private AsyncTaskDelegate _dlgt;

        // Create delegate.
        protected delegate void AsyncTaskDelegate();

        public String GetAsyncTaskProgress()
        {
            return _taskprogress;
        }
        public void DoTheAsyncTask()
        {
            // Introduce an artificial delay to simulate a delayed 
            // asynchronous task. Make this greater than the 
            // AsyncTimeout property.
            Thread.Sleep(TimeSpan.FromSeconds(5.0));
        }

        // Define the method that will get called to
        // start the asynchronous task.
        public IAsyncResult OnBegin(object sender, EventArgs e
,
            AsyncCallback cb, object extraData)
        {
            _taskprogress = "Beginning async task.";

            _dlgt = new AsyncTaskDelegate(DoTheAsyncTask);
            IAsyncResult result = _dlgt.BeginInvoke(cb, extraData);

                        return result;
        }

        // Define the method that will get called when
        // the asynchronous task is ended.
        public void OnEnd(IAsyncResult ar)
        {
            _taskprogress = "Asynchronous task completed.";
            _dlgt.EndInvoke(ar);
        }

        // Define the method that will get called if the task
        // is not completed within the asynchronous timeout interval.
        public void OnTimeout(IAsyncResult
 ar)
        {
            _taskprogress = "Ansynchronous task failed to complete " +
                "because it exceeded the AsyncTimeout parameter.";
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Page クラス
Page メンバ
System.Web.UI 名前空間
ExecuteRegisteredAsyncTasks
PageAsyncTask



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Page.RegisterAsyncTask メソッド」の関連用語

Page.RegisterAsyncTask メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Page.RegisterAsyncTask メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS