PictureBox.WaitOnLoad 属性

定义

获取或设置一个值,该值指示图像是否是同步加载的。Gets or sets a value indicating whether an image is loaded synchronously.

public:
 property bool WaitOnLoad { bool get(); void set(bool value); };
public bool WaitOnLoad { get; set; }
member this.WaitOnLoad : bool with get, set
Public Property WaitOnLoad As Boolean

属性值

Boolean

如果图像加载操作是同步完成的,则为 true;否则为 falsetrue if an image-loading operation is completed synchronously; otherwise, false. 默认值为 falseThe default is false.

示例

下面的代码示例演示如何使用 WaitOnLoad 属性。The following code example demonstrates how to use the WaitOnLoad property. 若要运行此示例,请将以下代码粘贴到包含名为的 PictureBox pictureBox1 和名为的的 Windows 窗体中 Button startLoadButtonTo run this example, paste the following code into a Windows Form that contains a PictureBox named pictureBox1 and a Button named startLoadButton. 请确保按钮的 Click 事件与 startLoadButton_Click 此示例中的方法相关联。Make sure that the Click event for the button is associated with the startLoadButton_Click method in this example. 您必须将图像文件路径更改为在您的系统中有效的路径。You must change the image file path to one that is valid on your system.

private void startButton_Click(object sender, EventArgs e)
{
    // Ensure WaitOnLoad is false.
    pictureBox1.WaitOnLoad = false;

    // Load the image asynchronously.
    pictureBox1.LoadAsync(@"http://localhost/print.gif");
}
Private Sub startLoadButton_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles startLoadButton.Click

    ' Ensure WaitOnLoad is false.
    pictureBox1.WaitOnLoad = False

    ' Load the image asynchronously.
    pictureBox1.LoadAsync("http://localhost/print.gif")

End Sub

注解

如果将 WaitOnLoad 属性设置为,则 true 表示以同步方式加载图像。Setting the WaitOnLoad property to true means the image is loaded synchronously. 这会导致用户界面阻止其他输入,直到加载该图像。This causes the user interface to be blocked from other input until the image is loaded. WaitOnLoad false (默认) 并且 LoadAsync 方法用于加载图像时,在加载 InitialImage 指定的图像时将显示图像,用户可以在加载过程中与该接口进行交互。When WaitOnLoad is false (the default) and the LoadAsync method is used to load the image, the InitialImage image is displayed when the specified image is loaded, and the user can interact with the interface during the load process.

适用于