Cannot Open Form Created on Separate Thread After Closing

My application communicates with a device that has several sensors.  As the sensors collect data, they send messages over the com port.  I have written a class to communicate with the device.  As the messages come in and are processed, the
class raises events that the application responds to.
The main window of the application handles the communication with the device and displays several statistics based on the data collected.  When the user presses a button on the device, a specific event is raised.  The main window create a separate
thread and opens a child window.  When the child window is open, the user opens a valve to dispense the product.  As the product is dispensed, a flow meter connected to the device measures the volume of product dispensed.  The flow meter generates
messages to indicate the volume dispensed.  I need to be able to send messages from the main window to the child window so that the child window displays the volume.  When the user is done, they close the valve dispensing the product and press the
"End" button on the child window.  The child window then updates several variables on the main window, makes a couple of database calls to record how much product was dispensed and by whom and then closes.
I need to run the child window using a separate thread as both windows need to be able to process commands.  If only one window has control the program doesn't work at all.  I have it figured out so that everything is working.  I can open
the child window, dispense product, se the amount of product dispensed in the child window (the main window processes commands from the device and updates the label on the child window using a delegate), closes the window (using Me.Close()) and updates the
main display with the updated data.  The problem is that when a user goes to dispense product a second time, I get the following error:
  A first chance exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll
  Additional information: Cannot access a disposed object.
I thought that maybe I could hide the window (change Me.Close() to Me.Hide) and then just show it.  When I do that I get this error:
  A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
  Additional information: Cross-thread operation not valid: Control 'frmPour' accessed from a thread other than the thread it was created on.
Both of these errors make sense to me, I just can't figure out how to make it work.
First I have to declare the child window as a global variable as I need to access the window from a couple of the event handlers in the main form.
Public frmMeasure As New frmPour
When the user presses the button on the device to dispense the product, the event handler executes this code to open the child window.
Private Sub StartPour(sAuthName As String, sAuthToken As String, iStatus As Integer) Handles Device.Pour
Dim th As System.Threading.Thread = New Threading.Thread(AddressOf Me.OpenDispenseWindow)
th.SetApartmentState(ApartmentState.STA)
th.Start()
End If
End Sub
Which executes this code:
Public Sub OpenDispenseWindow()
frmMeasure.sNameProperty = sCurrentUserName
frmMeasure.sAuthTokenIDProperty = sUserToken
Application.Run(frmMeasure)
bAuthenticated = False
bPouring = False
dSessionVolume += GetTapConversion(sCurrentValve) * iFinalTick
UpdateDisplayDelegate(iValveID)
End Sub
It doesn't matter if I use Me.Close() or Me.Hide(), both methods fail on the Application.Run(frmMeasure) line with the errors shown above. 
For the Me.Close() method, my thinking is that the global frmMeasure object is getting disposed when I close the child window.  Is there any way that I can re-instantiate it when I go to display the window again?
For the Me.Hide method, is there any way that I can track the thread that created it in the main window and when I go to call it a second time, detect that it is already available and just Show() it?
Any hints, tips or suggestions are appreciated.
Thanks.
John
John

To be honest, I have only grasped < 100% of your message in detail, but...: Windows that have a parent<->child relation must be running in the same thread. In addition, after closing a modeless window, you must not use it anymore. Instead, create
a new instance.
What happens if you do not create a new thread but instead open the child in the same thread (which is obligatory)? You wrote it doesn't work, but I don't know why?
"First I have to declare the child window as a global variable".
How do you define "global"? Normally this is a variable in a Module declared with the scope Public or Friend. But I guess you mean a field of the Form (a variable at class level in the Form).
"I need to be able to send messages from the main window to the child window so that the child window displays the volume."
Why does the main window has to send the messages? Can't the child window handle the device's messages itself?
"I need to run the child window using a separate thread as both windows need to be able to process commands."
Process commands from the device, or commands from the user operating the Forms?
Armin

Similar Messages

  • Photoshop CS6 cannot open or create new file.  This happened after running CCleaner

    Photoshop CS6 cannot open or create new file.  This happened after running CCleaner

    Hi, I've been asked to join this discussion. CCleaner is a nice tool, but if you used the Registry Cleaner that came with it, it might have done something to Photoshop's registry entries. There is that danger in using them.
    One thing CCleaner does is leave a backup of the registry, or you can use Windows System Restore to go to that point before you ran the Cleaner. Let's go with System Restore. Review the instructions.
    System Restore - Microsoft Windows
    If you suspect a virus, I'd like to direct you here http://bleepingcomputer.com/
    That would be the "Am I infected?" forum.
    They have the tools, you run them, and copy and paste the logs that are generated. They are very good at this, but it is super important you follow directions and don't leave until the process is completed.
    Gene

  • Please wait message when opening form created by Adobe LiveCycle Designer ES 9.0

    Problem
    Please wait message when opening form created by Adobe LiveCycle Designer ES 9.0
    Full message
    Please wait... If this message is not eventually replaced by the proper contents of the document, your PDF viewer may not be able to display this type of document. You can upgrade to the latest version of Adobe Reader for Windows®, Mac, or Linux® by visiting  http://www.adobe.com/products/acrobat/readstep2.html. For more assistance with Adobe Reader visit  http://www.adobe.com/support/products/ acrreader.html. Windows is either a registered trademark or a trademark of Microsoft Corporation in the United States and/or other countries. Mac is a trademark of Apple Inc., registered in the United States and other countries. Linux is the registered trademark of Linus Torvalds in the U.S
    Actions
    Updated Windows RT 8 to 8.1
    Uninstaled Adobe Reader Touch 1.3 and instaled 2.0 Build 84770
    Additional Information
    The form was created 10 or 11 months ago, and we are pretty sure that we were able to open it a while back
    The same PDF file opens just fine in Windows 8.1 using Adober Reader XI 11,0.06, it is only the app that is affected.
    The document cannot be opened by any other mobile app that we have tried or on another mobile OS (iOS)
    Any ideas?
    Thanks & Regards
    Jim

    The user's assertion is surprising to me, but perhaps I'm missing something important. I thought the correct position was from the conclusion of my earlier post "it can't be done". Adobe state their Reader Touch doesn't support XFA (http://blogs.adobe.com/readermobile/2012/12/13/adobe-reader-for-windows-8-tablets/). Unless (see that blog entry) you changed the type of form.

  • Upgraded Exchange to CU 7, now users cannot open emails in a separate window in webmail (OWA).

    Hello,
    Strange issue. I upgraded our Exchange 2013 to CU 7 and now users are reporting they cannot open emails in a separate window in OWA. Regardless of browser, browser version even regardless of another computer or mac. Chrome, Firefox, IE, Safari...same
    issue regardless of version numbers also.
    I've tested these settings on several laptops and I cannot open emails in a separate window. This happened a day after the upgrade. Previously this was working for all users. Now its hit or miss. Not all users are affected however. My mailbox/account is
    also a victim so I can test any theories out.
    Any suggestions would help and be appreciated.
    Thanks,

    Hi,
    Please check if there is any error message when these affected users try to open mail in a new window.
    Please check if these users can open messages in Outlook. This can help us to narrow the issue.
    And please check the aplication log in Exchange server to see if there is events related to this problem, which can help us to troubleshoot the issue.
    Best regards,
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Belinda Ma
    TechNet Community Support

  • I cannot open youtube videos to full screen after downloading the latest version of flash. HELP

    I cannot open youtube videos to full screen after updateding flash to the latest version (11. something) HELP! youtube says it is adobe's problem

    To help troubleshoot we'll need the following system information:
    Operating   system  
    Browser  
    Flash   Player version
    When reporting issues with video or audio, it's also helpful to get your system hardware and driver details.  Instructions for finding this information can be found here:
    Windows  
    Mac
    Finally, sometimes video and audio problems are caused at a lower level and not directly related to Flash Player.  I recommend trying both of the links below to see how they perform.  If the problem exists with both, then Flash Player is most likely not the culprit as the HTML5 video link does not use Flash Player when playing.  You can verify the use of HTML5 by right clicking the HTML5 video and looking for the words "About HTML5" at the bottom of the context menu.
    HTML5   video  
    Non-HTML5 video

  • HT201365 I cannot open/click my iCloud (iphone 4s) after upgrading to ios 7.0.6... How can I fix it?

    I cannot open/click my iCloud (iphone 4s) after upgrading to ios 7.0.6... How can I fix it?

    Hey AU Nicasio,
    Thanks for the question. If the iCloud tab (and other tabs) are greyed out, and you are unable to tap on them, it sounds like Restrictions have been enabled on your device. Specifically, the Restriction titled “Allow Changes: Accounts”.
    For more information, see this resource:
    iOS: Understanding Restrictions (parental controls)
    http://support.apple.com/kb/HT4213
    Thanks,
    Matt M.

  • Cannot open form in LifeCycle Designer to edit.

    I have created two forms using LC Designer 8. I now need to edit both forms and cannot open them back up to edit!
    When I try to open both forms Adobe Professional 8 opens. I then open the form in Adobe Pro 8 and click "edit in designer" and it will not open. I have also tried to open the form directly from my documents in LC Designer and it will not open.
    When I try to open LC deigner on its own it will not open - just shoots me straight to Adobe Pro 8.
    I need to edit these forms - please help! Thank-you :)

    I am also having this problem. It is a dynamic form bound to an XML schema. When I try to reopen it, the livecycle banner comes on, but disappears immediately. The pdf opens in acrobat 9 (a 30-day trial copy). From there, it can be distributed and then filled in.

  • Cannot open dng files using Photoshop CS4 after formatting my computer.

    I had  Photoshop CS4 installed at my desktop and because I couldn't open my raw files taken with my Sony A99 I downloaded DNG Data Converter.After that I was able to open my dng files using Photoshop CS4.After some months I formatted my computer and I reinstalled Photoshop CS4.Now I cannot open my older dng files and I get an error message.Also I cannot update my initial version of Photoshop from version 11.0.

    Mac or Win?
    Did you update Photoshop after reinstalling it?
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand, such as your platform (Mac or Win), exact versions of your OS, of Photoshop and of Bridge, machine specs, such as total installed RAM, scratch file HDs, video card specs, what troubleshooting steps you have taken so far, what error message(s) you receive, if having issues opening raw files also the exact camera make and model that generated them, etc., someone may be able to help you.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Unable to OPen Forms in a DR environment after logging in to Applications

    Hi,
    We are testing our DR(XP machines are part of the VMWare environment and the AIX OSes are on LPARs ) scenario and we were able to recover DB on DR database from production and had Application Code trees from prod...(Environment:AIX 64 BIT Powersystems, 11.5.10.2, 10.2.0.4)
    We are able to startup DB,Applicaiton services on DR site. After logging in to applications environement...we are able to open up Applicaiton manager/portal based responsibilities but not able to open forms. I dont see the jinitiator popup wizzard when opening the forms...(we ensured that there is java installed on the machine,no popup blockers)...
    Would appreciate your help and suggestions.
    Thanks,
    Hari

    Hi Hussein,
    Fyi, the Apache log had errors when run in configtest
    Syntax error on line 17 of /.../iAS/Apache/modplsql/cfg/plsql_pls.conf:
    Cannot load /..../iAS/Apache/modplsql/bin/modplsql.so into server: 0509-130 Symbol resolution failed for /..../iAS/lib/libclntsh.a(shr.o) because:
    0509-136 Symbol pw_post (number 261) is not exported from
    dependent module /unix.
    0509-136 Symbol pw_wait (number 262) is not exported from
    dependent module /unix.
    0509-136 Symbol pw_config (number 263) is not exported from
    dependent module /unix.
    0509-136 Symbol aix_ora_pw_version3_required (number 264) is not exported from
    dependent module /unix.
    0509-022 Cannot load module /..../iAS/Apache/modplsql/bin/modplsql.so.
    0509-026 System error: Cannot run a file that does not have a valid format.
    0509-192 Examine .loader section symbols with the
    'dump -Tv' command.
    adapcctl.sh: exiting with status 8
    This issues got resolved after running rootpre.sh
    Appreciate your quick response and all the help.
    Thanks,
    Hari

  • Iphone 5c, i cannot open emails that have multiple threads?

    I can open some of my email in my outlook account, however I cannot open an email that is part of a conversation with multiple threads?  Any help is appreciated!

    normally this means you are not or cannot connect to Apple server. Usually this is from a line in your Hosts file directing traffic away from the Apple server.
    Open your Host file using Notepad and see if you have a line that reads gs.apple.com if you do you will need to remove this line and you will be able to Restore after.
    You can Google or YouTube "how to edit host file" for help.

  • Cannot open .pdf created by InDesign CS6, can open all other .pdfs

    I just got InDesign CS6 at work (I use CC at home, but my company could not afford the CC subscription). I'm on PC with the minimum specs for InDesign and Photoshop Elements (also just installed). I have never been able to print to .pdf from InDesign; the program hangs. I have been doing Export to .pdf, press quality with my printer's specs. This has been working fine, except that, on occasion, I have to export the .pdf a few times to get it to open; it will give me an "either not a supported file or damaged" error message. Up until today, I have been able to export 2-3 times and would always get a .pdf that would open.
    As of today, I cannot open any .pdf at all; I get that same "not supported or damaged" error message. However, if I let my computer sit idle for about 30 minutes, it will open. In addition, after exporting, InDesign hangs on a background task of "Export " 5" and I have to close out of that task to do anything further in the program.
    I have read the forums on these issues and done what I can: I have installed all updates, backsaved to earlier Acrobat versions, exported to .idml, etc. Nothing helps.
    I will confess that I am not the most technically-savvy person by any means. My company is small and does not have an IT person, nor is there a budget for calling someone in, so it is up to me and my admittedly limited understanding of this software to fix this issue.
    Help?

    You may have shown me part of the problem. I can't share one of the files I'm working on, as they're full of images and we have client protections that make sharing problematic, but I did try to recreate a new file with garbage text and graphics and that .pdf opened without any problem.
    Could this be a file size issue? The files I'm working on are only 8,900 kb and 200 kb. That doesn't seem too large to me, but perhaps it's enough to cause a problem on my machine.

  • Cannot fill forms created by LiveCycle Designer

    Dear all,
         By using Adboe Reader for iPad, I can fill the forms created by Adobe Pro, but cannot view pdf and fill the forms created by LiveCycle Designer. Any idea?
    Thanks,
    Jackson

    Thanks for the reply. Right now I can create froms in Adobe Pro, but I need to create an "image file" which is only avialble in LiveCycle designer. Did the Acroforms you mention supports Image field? I tried to create a form with image fields in LiveCycle Designer, and then save as static form. It will work for PC but doesn't work for iPad.
    Thanks

  • Cannot open form with a button

    Hi folks, I'm new to Developer, so apologies.
    I am opening a form xxx by attaching a smart trigger of WHEN-BUTTON-PRESSED to a button by
    call_form('xxx');
    It compiles fine, but when I evesute the form, it says errer 400010 cannot read form. Any ideas?
    Thx,
    Ken

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Carter:
    Put the called form's fmx file in a directory specified in the FORMS60_PATH key in the registry
    <HR></BLOCKQUOTE>
    More simply, you can pass the parameter with the path. ie call_form('c:\xxx.fmx') and so.
    If you want to pass any other parameters check it in the help for call_form. Tip. You also can use run_form/new_form to call a new form and go_form to navigate b/w forms.

  • Cannot open form - Reader & Acrobat crash

    Hello,
    I am facing a strange issue here on our citrix servers (Win 2008 x64, Citrix PS 4.5)
    We have both Acrobat reader 9.4 and Acrobat Std 9.4 installed on the servers (problem occurs with verson 9.3 also)
    When we try to open some pdf files  (with either the reader or Acrobat), the window launches, and displays a part of the file, then the app crashes..
    Those pdf for which the issue occur all contain forms. I even tried generating a simple pdf form containing one text box, and the problem occurs.
    What is strangest is that if i save the file on disk (from say an email), I cannot open it. Consistently. This is always reproduced.
    If I logoff, then log back on, I can then consistently open it.
    It makes no difference if the file is saved on my desktop (we have roaming profiles), or in my home directory.
    This does not affect all pdfs, but all users for some pdfs..
    I have tried uninstalling one of the 2 products, but the other one keeps on crashing.
    Nothing in the event logs, I tried to procmon, could not spot anything.
    Any help would be VERY appreciated
    Vincent

    Hi
    Please follow this KB doc: http://helpx.adobe.com/acrobat/kb/reader-core-dll-error.html
    Thanks

  • Cannot open PDFs created by Morningstar Advisor Workstation with Preview

    I run my financial planning practice on my Macs using Parallels and Windows XP for Windows-only software and Internet Explorer only secure web sites. When I create PDFs using Morningstar's online application, Advisor Workstation, I cannot open these PDFs with Leopard's Preview of Mac app PDFPen Pro 4. Either apps starts to open the file, but the stalls and I get the dreaded spinning beach ball until I force quit the app.
    I resorted to installing Acrobat Reader 9 for Mac just to be able to read these PDFs. Using Reader, the troublesome files open instantly with no problems.
    Any suggestions?
    If Apple tech support is reading this, I have sample files to email you if you're interested.
    Bud James
    North Wales, PA

    Yes, the files are downloaded properly, because I can open them with the Mac version of Acrobat Reader or on any PC with Acrobat Reader.
    Regarding the comment on licensing issues, the latest version of PDFPen Pro cannot open the offending files either. I emailed sample files to the PDFPen Pro developers at SmileOnMyMac. They responded that they will examine the files I sent and let me know their engineers determine is the issue and, hopefully, their fix.
    Thanks for your comments.
    Bud James

Maybe you are looking for

  • Remote Desktop connection from Macbook to Win 2012 TS

    One of our users purchased a new Macbook (OS X Yosemite) and installed the MS Remote Desktop app to do work from home.  We've been trying to connect, we get to the logon screen, but there is a message that the user does not have Allow Logon through T

  • Odd message when trying to install 10.7

    Unable to install 10.7 though I get the message that my HD is the drive used for TM-backups

  • 11.2.0.3.3  impdp compress table

    HI ML : 源库 : 10.2.0.3 compress table target : 11.2.0.3.3 impdp 源端的compress tables,在目标端是否是compress table 之前在10g库直接 通过impdp dblink 导入时候 发现,入库的表需要手工做move compress. MOS 文档给的的测试时 在10g开始 支持导入自动维护compress table : Oracle Server - Enterprise Edition - Version

  • "Remotely Control LabVIEW Over the Web "in LabView 6.0

    Hello, is it possible that I realize "Remotely Control LabView Over the Web" in LabView6.0 ? Thanks a lot!

  • Automatically update option disabled in iTunes summary - no push happening!

    Changes I am making in Calendar and contacts does not appear to be pushing to my iPhone which is on 2.0. In iTunes summary page, the option to Automatically update the iPhone is disabled and unchecked - I can't change it - is this why the facility is