# Pages - Best Practices

The following are guidelines when creating Pages for your project:

- When constructing a Page, construct it with the goal of allowing them to be exported as Templates.

  - Use meaningful names for each element on the Page.
  - Use a naming convention for your standard Pages, e.g. "Overview", "Results", "Results_Details", "Settings", "Settings_Camera", "Diagnostics", etc.
- When constructing a project with multiple Pages, consider creating a single navigation pane, so navigation instructions do not have to be duplicated.
- For the Page Properties Display Methods (ShowPage/ClosePage) methods, use $Pages.{Page}.PageName to get the path of the page instead of using a hardcoded string (e.g. "Pages.{MyPage}").

- Do not call Task.{Task}.Run() from a UI, such as on a Button click command. Instead, use Task.{Task}.RunAsync().

  - The Run() call is a blocking call, and the UI will appear "frozen" until the Task completes, which may cause Windows to interpret your application as unstable, and then request to close it.
  - It may also cause the Cognex Designer program to lock up.

- Page elements, properties and methods (e.g. $Pages.{Page}.TextBox.Text) should only be used on the Main/UI Thread, and not on another thread, such as a Task.

  - Instead of accessing an element from another thread, bind the element to an intermediate tag, which will prevent cross-thread and performance issues.

  - If it is necessary to access a Page element on a Task thread, see the Update a VisionPro Display From a Task topic.

    Note: There is a performance penalty when accessing a Page property from another thread.

- When constructing a Button that will be used to launch an Open/Save file dialog, ensure that the pipe character (|) is placed in the correct location between the {display text} and the {filter} (e.g. {display text} | {filter}). The script below illustrates the proper use of the character (the script is used with the OnClick script of a Button in the FunctionSample ToolBlockEditor Page):

      string vppFilename = $FileSystem.ShowSaveFileDialog("Save ToolBlock", initialDirectory, "NewToolBlock", "VisionPro VPP|*.vpp");