{"id":8857,"date":"2015-03-09T09:50:00","date_gmt":"2015-03-09T16:50:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=8857"},"modified":"2015-03-24T14:34:31","modified_gmt":"2015-03-24T21:34:31","slug":"powershell-studio-knowing-when-to-use-sta-mode","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/","title":{"rendered":"PowerShell Studio: Knowing when to use STA mode"},"content":{"rendered":"<p><a class=\"twitter-follow-button\" href=\"https:\/\/twitter.com\/SAPIENDavid\" data-lang=\"en\">Follow @SAPIENDavid<\/a><\/p>\n<p>Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio.<\/p>\n<p style=\"padding-left: 30px\"><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAMode.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8920 size-full\" alt=\"SPS-STAMode\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAMode.png\" width=\"475\" height=\"163\" srcset=\"https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAMode.png 475w, https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAMode-300x103.png 300w\" sizes=\"auto, (max-width: 475px) 100vw, 475px\" \/><\/a><\/p>\n<p>STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into the detail, but you need not concern yourself with the inner workings of COM objects, other than to remember that STA is required for some of the GUI controls to function correctly.<\/p>\n<p>If you&#8217;re interested in the details, see <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms693344(v=vs.85).aspx\">Processes, Threads, and Apartmen<\/a><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms693344(v=vs.85).aspx\" target=\"_blank\">ts<\/a> in the Microsoft Developer Center.<\/p>\n<h2>Which controls require STA?<\/h2>\n<p>The following controls require STA mode. Otherwise, they do not appear.<\/p>\n<ul>\n<li>FolderBrowserDialog\n<li>SaveFileDialog\n<li>OpenFileDialog <\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>The following control features require STA mode.<\/p>\n<ul>\n<li>TextBox with AutoCompleteSource <\/li>\n<li>ComboBox with AutoCompleteSource <\/li>\n<li>DataGridView with Ctrl + C to copy text in cells.\n<li>Form with <em>TopMost<\/em> property set to <em>True<\/em>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Also, static methods of the Clipboard class require STA mode. For example:<\/p>\n<pre><span style=\"color: #000000\">[<\/span><span style=\"color: #0000cd\">System.Windows.Forms.Clipboard<\/span><span style=\"color: #000000\">]<\/span><span style=\"color: #0000ff\">::<\/span><span style=\"color: #000000\">SetText(<\/span><span style=\"color: #ff0000\">\"Paste this text to the clipboard\"<\/span><span style=\"color: #000000\">)<\/span><\/pre>\n<h2><b>Packaging and STA mode:<\/b><\/h2>\n<p>Luckily, PowerShell Studio detects when your form includes an STA mode dependent control and runs it in STA mode. But, when you package a script, be sure to retain the STA mode settings.<\/p>\n<p>Click <b>Deploy<\/b> and in the Packager section, click <b>Settings<\/b> and then <b>Engine Settings<\/b>.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAModePackager.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8921 \" alt=\"SPS-STAModePackager\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAModePackager.png\" width=\"647\" height=\"126\" srcset=\"https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAModePackager.png 796w, https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAModePackager-300x58.png 300w\" sizes=\"auto, (max-width: 647px) 100vw, 647px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Next, make sure that your Windows PowerShell scripts require STA when running. If you add the following comment to your script, PowerShell Studio and PrimalScript run the script in STA mode:<\/p>\n<pre><span style=\"color: #008000\"># %ForceSTA% = True<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>Starting in Windows PowerShell 3.0, the Windows PowerShell console runs in STA mode by default. If you are using Windows PowerShell 2.0, use the following command to start Windows PowerShell with the STA option:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PowerShell.exe \u2013STA<\/p>\n<p>Windows PowerShell ISE always runs in STA mode.<\/p>\n<p>&nbsp;<\/p>\n<p>To determine whether a Windows PowerShell host program is running in STA mode, use this command to check the value of the <em>ApartmentState<\/em> property:<\/p>\n<pre><span style=\"color: #8b0000\">$host<\/span><span style=\"color: #000000\">.Runspace.ApartmentState<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>STA mode is not something you normally have to consider when writing scripts, but it is something that you should be aware of if you are creating GUIs tools. Most GUIs will run fine in MTA mode, but as a general rule, we recommended that you always run your GUI scripts in STA mode.<\/p>\n<p><em><\/em>&nbsp;<\/p>\n<p><em>David Corrales is Senior Software Engineer at SAPIEN Technologies, Inc. F<\/em><em>ollow him on Twitter at <a href=\"https:\/\/twitter.com\/SAPIENDavid\" target=\"_blank\">@SAPIENDavid<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,644],"tags":[665,41,958,1016,538,997],"class_list":["post-8857","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-spotlight-on-controls","tag-form","tag-gui","tag-mta","tag-powershell-studio","tag-sta","tag-windows-powershell"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"David Corrales\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DEV SAPIEN Blog - Tools for IT Success\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2015-03-09T16:50:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2015-03-24T21:34:31+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#blogposting\",\"name\":\"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog\",\"headline\":\"PowerShell Studio: Knowing when to use STA mode\",\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/www.sapien.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/SPS-STAMode.png\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#articleImage\"},\"datePublished\":\"2015-03-09T09:50:00-07:00\",\"dateModified\":\"2015-03-24T14:34:31-07:00\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#webpage\"},\"articleSection\":\"PowerShell Studio, Spotlight on Controls, Form, gui, MTA, PowerShell Studio, STA, Windows PowerShell\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"name\":\"Software News\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"position\":2,\"name\":\"Software News\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/powershell-studio\\\/#listItem\",\"name\":\"PowerShell Studio\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/powershell-studio\\\/#listItem\",\"position\":3,\"name\":\"PowerShell Studio\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/powershell-studio\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#listItem\",\"name\":\"PowerShell Studio: Knowing when to use STA mode\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"name\":\"Software News\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#listItem\",\"position\":4,\"name\":\"PowerShell Studio: Knowing when to use STA mode\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/powershell-studio\\\/#listItem\",\"name\":\"PowerShell Studio\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/\",\"name\":\"David Corrales\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#webpage\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/\",\"name\":\"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog\",\"description\":\"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2015\\\/03\\\/09\\\/powershell-studio-knowing-when-to-use-sta-mode\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\"},\"datePublished\":\"2015-03-09T09:50:00-07:00\",\"dateModified\":\"2015-03-24T14:34:31-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog","description":"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into","canonical_url":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#blogposting","name":"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog","headline":"PowerShell Studio: Knowing when to use STA mode","author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author"},"publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/03\/SPS-STAMode.png","@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#articleImage"},"datePublished":"2015-03-09T09:50:00-07:00","dateModified":"2015-03-24T14:34:31-07:00","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#webpage"},"isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#webpage"},"articleSection":"PowerShell Studio, Spotlight on Controls, Form, gui, MTA, PowerShell Studio, STA, Windows PowerShell"},{"@type":"BreadcrumbList","@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/dev.sapien.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","name":"Software News"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","position":2,"name":"Software News","item":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/powershell-studio\/#listItem","name":"PowerShell Studio"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/powershell-studio\/#listItem","position":3,"name":"PowerShell Studio","item":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/powershell-studio\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#listItem","name":"PowerShell Studio: Knowing when to use STA mode"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","name":"Software News"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#listItem","position":4,"name":"PowerShell Studio: Knowing when to use STA mode","previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/powershell-studio\/#listItem","name":"PowerShell Studio"}}]},{"@type":"Organization","@id":"https:\/\/dev.sapien.com\/blog\/#organization","name":"DEV SAPIEN Blog","description":"Tools for IT Success","url":"https:\/\/dev.sapien.com\/blog\/"},{"@type":"Person","@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author","url":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/","name":"David Corrales"},{"@type":"WebPage","@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#webpage","url":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/","name":"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog","description":"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/#breadcrumblist"},"author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author"},"creator":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author"},"datePublished":"2015-03-09T09:50:00-07:00","dateModified":"2015-03-24T14:34:31-07:00"},{"@type":"WebSite","@id":"https:\/\/dev.sapien.com\/blog\/#website","url":"https:\/\/dev.sapien.com\/blog\/","name":"DEV SAPIEN Blog","description":"Tools for IT Success","inLanguage":"en-US","publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"DEV SAPIEN Blog - Tools for IT Success","og:type":"article","og:title":"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog","og:description":"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into","og:url":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/","article:published_time":"2015-03-09T16:50:00+00:00","article:modified_time":"2015-03-24T21:34:31+00:00","twitter:card":"summary_large_image","twitter:title":"PowerShell Studio: Knowing when to use STA mode - DEV SAPIEN Blog","twitter:description":"Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn\u2019t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into"},"aioseo_meta_data":{"post_id":"8857","title":null,"description":null,"keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-08-28 15:34:47","updated":"2026-08-28 15:34:47"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/\" title=\"Software News\">Software News<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/powershell-studio\/\" title=\"PowerShell Studio\">PowerShell Studio<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPowerShell Studio: Knowing when to use STA mode\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dev.sapien.com\/blog"},{"label":"Software News","link":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/"},{"label":"PowerShell Studio","link":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/powershell-studio\/"},{"label":"PowerShell Studio: Knowing when to use STA mode","link":"https:\/\/dev.sapien.com\/blog\/2015\/03\/09\/powershell-studio-knowing-when-to-use-sta-mode\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/8857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=8857"}],"version-history":[{"count":18,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/8857\/revisions"}],"predecessor-version":[{"id":8963,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/8857\/revisions\/8963"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=8857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=8857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=8857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}