{"id":5189,"date":"2018-08-15T01:51:22","date_gmt":"2018-08-15T08:51:22","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=5189"},"modified":"2018-08-15T01:51:22","modified_gmt":"2018-08-15T08:51:22","slug":"refresh-session-0","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/refresh-session-0\/","title":{"rendered":"Q &#038; A: My VB6 App Doesn&#8217;t Refresh in Session 0 \u2014 Help!"},"content":{"rendered":"<div class=\"blog-qa-question-box\">\n<img decoding=\"async\" src=\"\/images\/quotes-transparent-21x21.png\">&nbsp;&nbsp;We have a VB6 application we&#8217;re running as a service in <a href=\"\/products\/AlwaysUp\/\">AlwaysUp<\/a> on Windows Server 2012 R2. When we run the application outside of AlwaysUp, the form refreshes fine. When we run the application in AlwaysUp, it can sometimes take several minutes for the form to refresh, starting out as a black form (see screenshot of Session 0 below). Any recommendations you might have to help with the refresh rate would be appreciated, thanks.<\/p>\n<div align=\"center\"><a href=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/app-not-refreshing-in-session-0.png\" class=\"zoomPopup\" title=\"Application not refreshing in Session 0\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/app-not-refreshing-in-session-0.png\" title=\"Application not refreshing in Session 0 (click to enlarge)\" alt=\"Application not refreshing in Session 0\" border=\"0\" width=\"520\" ><\/a><\/div>\n<p align=\"right\">&#8212; Jim Kinghorn, Taylor Technology Services<\/p>\n<\/div>\n<p>Hi Jim. You are running into one of the peculiarities of Session 0 &mdash; where user interface elements do not seem to be refreshed consistently. Unfortunately it is a &#8220;Windows thing&#8221; and is outside the control of AlwaysUp.<\/p>\n<p>But all is not lost! Our development team took a look at your situation and concluded that calling the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/api\/winuser\/nf-winuser-redrawwindow\" target=\"_blank\" rel=\"noopener noreferrer\">Windows RedrawWindow API function<\/a> in Session 0 might fix the problem.<\/p>\n<p>You have a couple of options:<\/p>\n<h2><b>Option #1: Update your code to refresh all windows periodically<\/b><\/h2>\n<p>Specifically, your code should:<\/p>\n<ul>\n<li>\n<p>\nRefresh the desktop window, by calling the VB6 equivalent of:<\/p>\n<blockquote><p><b>RedrawWindow(NULL, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN)<\/b><\/p><\/blockquote>\n<\/li>\n<li>\n<p>\nEnumerate all top-level windows (using the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms633497(v=vs.85).aspx\" target=\"_blank\" rel=\"noopener noreferrer\">EnumWindows API function<\/a>) and call RedrawWindows on each visible window.\n<\/p>\n<\/li>\n<\/ul>\n<p>Performing those operations every few seconds should eliminate the black windows in Session 0.<\/p>\n<h2><b>Option #2: Setup our &#8220;RefreshWindows&#8221; utility to run in Session 0<\/b><\/h2>\n<p>If updating the code is not a viable option, you can:<\/p>\n<ul>\n<li>\n<p>\nDownload our free <a href=\"\/download\/RefreshWindows.exe\">RefreshWindows<\/a> command line utility and save it to a folder of your choice. When run, the utility refreshes all windows every 5 seconds (using the RedrawWindows and EnumWindows functions as recommended above):\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/refreshwindows-running.gif\" class=\"zoomPopup\" title=\"Running RefreshWindows\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/refreshwindows-running.gif\" title=\"Running RefreshWindows (click to enlarge)\" alt=\"Running RefreshWindows\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nSet it up as a Windows Service with AlwaysUp. All you should have to provide is the full path to the executable file on the &#8220;General&#8221; tab:<\/p>\n<div align=\"center\"><a href=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/setup-refreshwindows.png\" class=\"zoomPopup\" title=\"Setup RefreshWindows as a Windows Service with AlwaysUp\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"https:\/\/cdn.coretechnologies.com\/blog\/images\/setup-refreshwindows.png\" title=\"Setup RefreshWindows as a Windows Service with AlwaysUp (click to enlarge)\" alt=\"Setup RefreshWindows as a Windows Service with AlwaysUp\" border=\"0\" width=\"520\"><\/a><\/div>\n<\/li>\n<\/ul>\n<p>When your machine boots, AlwaysUp will launch RefreshWindows.exe to ensure that all windows in Session 0 are periodically refreshed and properly drawn.<\/p>\n<p>Enjoy!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/run-python-script-every-hour\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"How to Run a Python Script Every Hour, On the Hour\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/python-logo-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">How to Run a Python Script Every Hour, On the Hour<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/video-start-dropbox-whenever-your-pc-boots\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Start Dropbox whenever your PC boots\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/dropbox-logo2-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Video: Start Dropbox whenever your PC boots<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/how-to-move-alwaysup-services-new-server\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"How do I Move my AlwaysUp\/Windows Services to a New Server?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/transfer-alwaysup-to-new-server-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">How do I Move my AlwaysUp\/Windows Services to a New Server?<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;We have a VB6 application we&#8217;re running as a service in AlwaysUp on Windows Server 2012 R2. When we run the application outside of AlwaysUp, the form refreshes fine. When we run the application in AlwaysUp, it can sometimes take &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/refresh-session-0\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3560,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,91,127,130,153,161,174,179],"class_list":["post-5189","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-interactive-services","tag-qa","tag-refresh-windows","tag-session-0-isolation","tag-product-support","tag-vb6","tag-visual-basic"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=5189"}],"version-history":[{"count":0,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5189\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/3560"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=5189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=5189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=5189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}