method accewwing from another thread causes some 'bad object type' error with c# VS2008

I'm snapping a picture to a main Viewer, draw a rectangle around an alignment and extract the part of the image to a different viewer for further processing. I tried everthing and all was good until I started to build a Wizard for the operator through the process of the market and do things automatically. If I have access to this method of the mainform thread, everything works fine. If I access it from the thread of substantive assistants work it fails and gives the error "you have provided the wrong type of object to the function. Spend a CWIMAQRectangle instead. »

public int ExtractToGP1()

{

CWIMAQLearnPatternOptions LearnOptions = new CWIMAQLearnPatternOptions();
CWIMAQRectangle RoiRectangle = new CWIMAQRectangle();

int Count, result;

Extract the region corresponding to the model selected in the main Viewer

Result = axCWMachineVision1.GetSelectedRectangleFromViewer (axCWIMAQViewer1.GetCWIMAQViewer (), RoiRectangle, true, 1); //<--error>

Result = axCWIMAQVision1.Extract2 (axCWIMAQViewer1.Image, axCWIMAQViewer5.Image, RoiRectangle, 0, 0);

I tried to use:

axCWMachineVision1.Invoke (delegate (MethodInvoker)

{Result = axCWMachineVision1.GetSelectedRectangleFromViewer (axCWIMAQViewer1.GetCWIMAQViewer (), RoiRectangle, true, 1) ;})} ;

axCWMachineVision1.Invoke (delegate (MethodInvoker)

{Result = axCWIMAQVision1.Extract2 (axCWIMAQViewer1.Image, axCWIMAQViewer5.Image, RoiRectangle, 0, 0) ;})} ;

but this only works if the method is called by the main thread.

Resolved to myself. Not really a problem of OR.

I moved

CWIMAQLearnPatternOptions LearnOptions = new CWIMAQLearnPatternOptions();

CWIMAQRectangle RoiRectangle = new CWIMAQRectangle();

for my vision instead of having it in the method class, which is in the mainform class

Then use Vision.RoiRectangle vs RoiRectangle and Vision.LearnOptions vs LearnOptions.

Tags: NI Hardware

Similar Questions

  • panels and multithreading - what features can I call from another thread.

    I am writing a program (Windows XP, LabWindows/CVI 2010) that has several threads. The main thread generates and manages most of the panels, but not all. Is there a list of what control panel functions are thread-safe and which are not? Reading the help file and the different positions, the functions of set value are safe; game-attribute functions are NOT. (I found that calling (SetPanelAttribute) with ATTR_TITLE will be locked permanently a program!). What about calliing a command callback function? (Via the CallCntrlCallback() function). It seems to work very well so far, but I can't find anything definitive.

    I do a lot of multi-thread applications, so I have a few ideas for you.  Unfortunately, I have not tried to do many of the changes of attributes specific threads lower panel.

    I'm very careful about how I handle the wire "solidity", dealing with the variables in an asynchronous way, as much as possible, to avoid the use of blocking and incorrect values of the variables.

    But there are certainly many things simply cannot make you the son of the daughter.  Things like question popups and launch other threads cannot be done simply.  As long as you understand that the best place to do something is in the main thread, and then a girl thread can use PostDeferredCall (...), do something in the main thread

    In the thread of your daughter, you can insert this call:

    PostDeferredCall (launchNewThread, 0);

    And then this call performs this function in the main thread:
    void CVICALLBACK launchNewThread(void *callbackData)

    {
    CmtScheduleThreadPoolFunction (threadPoolHandle, NewThread, NULL, NULL);
    }

    Or you can insert calls from parameter of the attribute panel inside the function above, I suppose, to safely run in the main thread.

    Hoe, that helps...

    -Gary

  • The default value based on the field from another table to a custom object

    I'm trying to set the default value to a field in the custom object to the value of a field of account. I tried the syntax 50 ways different and just don't get the case. The label for the account field displays the form of s/n, the integration of the tag is ltDBA_ACCT and it appears in the fx reports area as Account.Text_22.

    The field of custom object that I am triying update is also called s/n, which was originally the required field 'NAME '. The name of the table, account, should it be included? Do I need a function to the field?

    I've updated the external ID using the line with syntex < ID > ID (at least higher ID) so I know that it is possible to define a default value, but s / < n >, < ltDBA_ACCT >, 'account '. "" S/n "and so on are simply not working.

    If anyone knows how to get into what I would be really grateful for the help.

    OK, so if you default a field to the value of another object, you must use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure you do.

    Then this won't work by default if the folder is created from the object that you want to join the because a default works in record creation and the ID must be available so that it works correctly. It will not work if you choose the record of the related object after that registration of the custom object is created. You can set the default after, but that does not meet your requirements.

    The syntax of the default are the following: JoinFieldValue (ref_record_type, foreign_key, field_name).

    In your case, ref_record_type is '', foreign_key is [] and field_name is ''. The best way is to determine what is the name of the field to create a new workflow for the account and use the Workflow Rule Condition expression builder to choose your field ("DBA") in the list. The value returned by the expression builder must be placed in the field_name variable in the function JoinFieldValue (minus the parentheses and quotes).

    Give it a shot and let me know how you do.
    Thom

  • Opening files from the desktop causes to try to be open with WorkPerfect instead of Word

    When I try to open a document in the office, I receive a message indicating that it tries to open it with WordPerfect instead of the word.  Why this happens when I want, he opened with Word.

    Hello

    Go to Control Panel/Default Programs/Set file associations. Scroll down to the file type (.doc/.docx) and select it, then click on "program change" and choose a Word from the list, or click Browse for the word.exe file.

    Good luck, Rick Rogers, aka "Crazy" - Microsoft MVP http://mvp.support.microsoft.com Windows help - www.rickrogers.org

  • Source is taken from another Source of Transaction the assets of RMA with SB

    Hello!

    I created a Type of Transaction to have this attached to a Source of the Transaction to the Type of Transaction Standard column and this and that is attached to the Source column of the invoice of the tab Finance installation of Types of transactions for RMA on the order management program.  Whenever I am billing with this transaction type of RMA RMA, the A.R. transaction created has a different Source of what I put. Is there such a thing as a type of transaction 'by default'? What I'm missing here?

    Thank you.

    Jon

    Hello! Thanks for the reply!

    I saw the problem, the entry in the Type default return line in the Types of transactions OM has entered in the Source of the invoice and is selected as the Source of the AR.

    Thank you.

    Jon

  • User-defined function: BAD ARGUMENT TYPE, ERROR

    I am creating a function defined by the user, named DOTAN, to calculate the angle between two vectors X and Y.  The UDF looks like this: DEFINE (' DOTHAN (X, Y) = ACOS (DOT (X, Y) / (ABS (X) * ABS (Y)))')--> (see pic attached to the actual Calculator display).  The problem is that I can not set because as soon as I hit ENTER I get the warning: DEFINE ERROR: wrong Type of Argument.  I tested each component separately and I am sure that the problem is with the help of DOT (X, Y) inside a UDF, but I don't know why. Maybe I'm missing some setting related to the use of functions which take an argument that is greater than 1 inside a UDF. Just guessing. Any idea?

    Thank you

    for some reason, the DOWRY is a commandment and not a function for the 50G.

    You cannot use DOT in a function, you maybe wrote a program

    in RPL

    '--> x, y   '  x y DOT  XY ABS ABS * / ACOS   ' ""DOTHAN"STO

    [3.0] [0.3] DOTAN
    back 90 degrees

    I never use the algebraic mode but I guess it's the same thing with a program...

  • you are trying to download items 13.  do 'bad file type' error message

    After downloading the new 13 items, I try to run it, and it tries to open in 11 elements.  I get an error message that it can't open because it's the wrong type of file. I'm using window 8.1 (64-bit).  Someone had a similar problem?  How can I solve the problem?

    Have Fred Hoerauf you installed Photoshop elements 13?  What file name and extension you are trying to open in Photoshop elements 11?

  • In another thread - another method and then run Sub...

    I wrote a method to extract a string from a webpage using StreamConnection and it works perfectly... except that it runs on the main thread.  I wonder if there is a simple way to have a method that returns an object (String in this case) something to run on a thread and return it to the first thread.

    Everything I try the only thing I can get to work on the second thread is what's on the run method void, but that returns nothing... because it sucks...

    Until now what I thought is to pass the variables I need in the constructor, then set the connection stream real term where I want retruned is written in a class variable and another method that returns the class variable that has been filled with the run method... but that doesn't seem to just... thought he worked in a simple test I ran...

    A slightly different way (but completely equivalent) to work in a another thread is to create a class that implements Runnable and feed a thread. If, for any reason, you do not want to expand Thread (because your worker class extends already something else and it would be difficult to refactor), then this variant is a lifeline. You do something like this:

    class WorkerClass extends AnotherClass implements Runnable {    // ...    public void run() {       // do time-consuming work here    }}
    
    // later...WorkerClass worker = new WorkerClass();// initialize worker object. Then: new Thread(worker).start();
    

    As it is easy to turn a class in an executable (you simply add "implements Runnable" and a run() method), it's an easy way to avoid the subclassing Thread.

    Regardless of how you use to perform work in a separate thread, there is always the question of how to get the results. With the help of the observer is a common way to handle this, but in general, this means that the results are returned in the worker thread, not the thread from the main event. If you want to update the user interface, this can be a problem. Another approach is to structure your code something like the following:

    /** * Process the results of some time-consuming operation. */public void acceptResults(ResultType result) {  // ...}
    
    /** * Start a thread to carry out time-consuming work in a * separate thread and deliver the results back in the * event dispatching thread. */public void launchWork() {  new Thread() {        public void run() {           final ResultType res = computeResults();          Runnable r = new Runnable() {                public void run() {                   acceptResults(res);               }         }         Application.getApplication().invokeLater(r);      }
    
           /**        * Do time-consuming work in this method       */       private ResultType computeResults() {         // connect to server, interpret reply, etc.       } }.start();}
    

    You have the right idea that is running in a thread separate is how to manage a time consuming task. The point of all, however, is that you (the event dispatching thread) don't want to wait for the task at hand. Both the observer model and the code here offer a solution for a worker thread to do the work without blocking the thread of the event. The invokeLater() method was kindly provided by BlackBerry people to give the worker threads neatly transfer control on the event dispatching thread when needed.

  • The same method works OK a bean, cause of error in another

    For the experienced:

    I use JDeveloper 10.1.3.4 and the backup of a page bean, to get an instance of a module application I do this way:
        public ZBOVStaffModuleImpl getZBOVStaffAm() {
            FacesContext fc = FacesContext.getCurrentInstance();
            ValueBinding vb = fc.getApplication().createValueBinding("#{data}");
            BindingContext bc = (BindingContext)vb.getValue(fc);
            DCDataControl dc = bc.findDataControl("ZBOVStaffModuleDataControl");
            ApplicationModule am = (ApplicationModule)dc.getDataProvider();
            return (ZBOVStaffModuleImpl)am;
        }
    
        public String commandButton1_action() {
            ZBOVStaffModuleImpl zbovStaffModule = getZBOVStaffAm();
            // ... lines omitted
            return null;
        }
    Before you add only one line in the commandButton action method, it can be called and clicked commandButton1 without causing any problems. Now, simply by adding a line that calls the getZBOVStaffAm() method when you click commandButton1, I got the error in the browser:
    javax.faces.FacesException: #{staffLogin.commandButton1_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException
    I removed the line in the commandButton1_action() method and copied the lines of the getZBOVStaffAm() to the commandButton1_action() method method, one line at a time and run the pages and found that when this last line shown here is added, the error has been spilled in the browser:
        public String commandButton1_action() {
            FacesContext fc = FacesContext.getCurrentInstance();
            ValueBinding vb = fc.getApplication().createValueBinding("#{data}");
            BindingContext bc = (BindingContext)vb.getValue(fc);
            DCDataControl dc = bc.findDataControl("ZBOVStaffModuleDataControl");
            ApplicationModule am = (ApplicationModule)dc.getDataProvider(); // line causing problem
            // ...
            return null;
        }
    I have no idea why this line would spill error. The getZBOVStaffAm() method is copied word for Word from another bean of support, and in this bean support, this method is called in the same way but has not caused any problems. I checked doulbe ZBOVStaffModuleDataControl data control name is correct. Hope that experienced developers would have some suggestions.

    My application is in two parts. For the part of the student, the application module is ZBOVModule. During the construction of the part of the staff, I added the ZBOVStaffModule and built pages and tested features, without joining them with cases of navigation. The bean to support one of these pages, I created this getZBOVStaffAm() methods to avoid repeating the same code. And it has worked very well.

    Now all these pages are built and worked, I restarted right at the end of the part of the student, created a diagram vacuum staff-faces - config.xml for testing each reconstructed page, adding the login page and join them in case of navigation. But leader, in the first two pages involving login and required the use of the getZBOVStaffAm(), I went to the problem described above.

    Thanks a lot for your help!

    Newman

    Hello Newman,

    I see nothing wrong in your code.
    Do you have links in your pagedefinition? If this isn't the case, you can try adding just a few link by drag / drop some attribute on the page and see.

    Sometimes back I faced the same question when I don't have the links in my pagedefinition and adding a component and linking to some datacontrol method/attribute this problem resolved. Not sure if this is a bug, but you can give it a try.

    Jean Lou

  • What would cause the "from address" info (FA). some emails, downloading the pop3 server, will be replaced by an 'f' 'common '?

    I get multiple research work emails (E/JS) and ecommerce. Some of them have a "Correct".
    'St. Michael Job Assistance Ministry - JAM' FA (SMJAM-JAM).

    For some reason, however, some of the emails from other sources, downloading the verizon pop3, E/JS server are indicated (wrongly) as having the FA SMJAM-JAM above. This situation prevents my email filters to plug these emails to their appropriate mail folder.

    Also, when the steps in order to transmit emails showing incorrect information of FA SMJAM-JAM, the e-mail is no longer present incorrect information of FA SMJAM-JAM but shows rather the correct information of FA that had been specified on the verizon pop3 server.

    address ROM"(FA) in some emails, when downloading from the pop3 server, is replaced by a 'common' 'FA '. [email protected]

    What would cause the "from address" info (FA). some emails, downloading the pop3 server, will be replaced by an 'f' 'common '?

    Hello

    If I understand your problem, I think it may have to do with the addresses stored in your address book. Thunderbird can display the name of your address book instead of the name of the post office, where corresponds to the e-mail address.

    Check your address books to see if you have a bad entry for mail addresses get listed wrong.

    Also check under Tools-> Options-> advanced-> reading & display if you have checked the option to see show it only the names of the people in my address book. If you uncheck this option, the name and the address must be...

  • Call the method from another application

    Then. That is my question. Is it possible to call a method from another application, so I can get some data from this app?

    I know that I could also do this with persistent store, but I would like to do it this way.

    Thank you. I'll try with world events and TIME store.

  • methods of a JavaFX application from another application

    Hallo.

    So, I did some work on JavaFX 2.0 integrating graphics into a program called Max/MSP. It is a kind of Visual language for handling the music. Among it's features is the ability to write your own classes java, extended by the MaxObject class and create the custom components in your Max Patches. I received a MaxObject to launch a JavaFX applications, so I know that this part can be done. Now, I need two programs to talk properly with each other.

    So, what I'm looking for is a pretty standard, reliable way to get ApplicationA, i.e. which launches application (and thusly can pass arguments by hand), to be able to transmit information in application B and vice versa. I'm assuming that someone else out there he wanted a JavaFX application to interface with another piece of java code. An Advisor on what should I look for in? Both applications are running on the same computer. And I hope my question is clear decently...
    -Jean

    Hey John,

    I would like to try some of the following to refine your question:
    * Put your launch within another thread code to see if that stops the problem of blocking
    * use a random value that is passed to your application instead of 42 so that you can tell if new instances are created, etc.
    call a different method for bang for your second call to the method just separate the flow to isolate your question

    Something like:

    public class MaxPart extends MaxObject {
    
        private boolean started;
        private Circles circles;
    
        public synchronized void bang()
        {
            if (!started)
            {
                outlet(0, "Starting Circles application...");
                started = true;
                new Thread()
                {
                    public void run()
                    {
                        Application.launch(Circles.class, null);
                        outlet(0, "Circles application launch completed");
                    }
                }.start();
    
                // you could do some synchronized blocking here to wait for the instance to be set, try just doing a
                // simple sleep for now and add synch in if it works
                try { Thread.sleep(2000); } catch (InterruptedException e) {};
    
                circles = Circles.instance;
                Double randomValue = Math.random();
                outlet(0, "Circles assigned random value: " + randomValue);
                circles.setValue(randomValue);
            }
            else
            {
                outlet(0, "Circles is already started, not starting another one");
            }
        }
    
        public void anotherBang()
        {
            outlet(0, "Circles random value was: " + circles.getValue());
        }
    }
    

    Either way, you mention that you want to use the Singleton pattern. You pretty much are already - the 'instance' is a singleton that gets the value once (when the Application is launched) and is then used in the world. There is nothing real magic of singletons.

    Also, just to let you know the 'main' method in your application of circles is not needed or used. The bang method directly calls the launch. You only need this main method if you want to run the standalone app of circles (which is still useful for testing).

    Hope that helps,
    zonski

    Did you find this answer useful? If so, please indicate as 'correct' or 'useful '?

  • MenuItems run() method that is called from the thread eventdispatching?

    Hello

    is it? I know that MenuItem itself extends thread, but I wonder why this method is called run() and finally and above all it would'nt be worse if this method would be called from a Thread.

    THX

    In fact the menu items are run on the thread of the event. You can see this by creating a menu item long-term. The menu will not close and will not refresh the screen.

  • Homegroup is very slow. Loading files from another computer is very long and I can't watch movies on the wireless using the homegroup.

    Group residential slow and other problems with it

    Hello!

    I have 3 Windows 7 PC-s (office #1, #2 desktop and laptop). I created HomeGroup and join all computers, so I can access the files on each of them. But my problem is the following: homegroup is very slow. Loading files from another computer is very long and I can't watch movies on the wireless using homegroup, because it is slow and every two seconds of loading film. And also needed a few minutes to open the pictures (more than 10 GB in all folders) to a folder in the other PC. Why is this work so slow? I don't think there is a problem with slow wireless router, because I can replace my old Linksys WRT54GL Linksys E4200, which is able to transfer video HD 3D such as Linksys provide. What should I do to fix this? Should I change all the settings in Windows, perhaps in the router...?
    And why my laptop is not always visible to the other PC to homegroup? He see two others and two other sees, but they are not portable. This happens sometimes. But then I still share with homegroup libraries to my laptop and there still other computers see it and all shared libraries. Where is the problem? I also try to change the HomeGroup services automatically, but this does not solve the problem.
    If I forgot something to write, or you need more information, do not hesitate to ask.
    I'd appreciate any help really.

    Hello

    Manually check manufacturers sites WiFi because pilots offered through
    Updates Windows will most often not be later (MS is far behind certifying)
    drivers and many manufacturers do not quickly submit newer versions or not at all). See
    Manual driver update of the methods below.

    The question could be WiFi in fact however try to device (hardware)
    update the driver first.

    What antivirus/security is used? Some of those who will cause problems with the
    Homegroup. Since it happens more often on a single computer that on there
    a check.

    From this link:

    Homegroup: frequently asked questions (also shows how delete and remove homegroup)
    http://Windows.Microsoft.com/en-us/Windows7/HomeGroup-frequently-asked-questions

    "Only people who belong to the homegroup can see shared libraries. You can also share libraries or files and individual folders with specific people in your homegroup, rather than share them with everyone. For more information, see libraries with your homegroup sharing and keep files and folders to be shared with a specific residential group. »

    Share files with anyone
    http://Windows.Microsoft.com/en-us/Windows7/share-files-with-someone

    ==================

    How to upgrade manually the drivers:

    Control Panel - network - write down of the brand and the model of the Wifi - double click top - tab of the driver - write
    version - click the driver update (cannot do something that MS is far behind the pilots of certification). Then
    Right click on the Wifi device and UNINSTALL - Reboot - it will refresh the driver stack.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    Installation and update of drivers under Windows 7 (updated drivers manually using the methods
    below is preferred so that the latest drivers from the manufacturer of system and device manufacturers are
    found)
    http://www.SevenForums.com/tutorials/43216-installing-updating-drivers-7-a.html

    Download - SAVE - go where you put it - right click – RUN AS ADMIN.

    You can download several at once however restart after the installation of each of them.

    After watching the system manufacturer, you can check the manufacturer of the device an even newer version.
    (Those become your fonts of rescue system manufacturer).

    Repeat for network (NIC) card and is a good time to get the other updated drivers as windows
    7 love the updated drivers.

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">

  • Try to update the user interface with another thread

    Hello

    Start a class JavaFX from another application, and then I want to change the UI of it components. I tried to use Platform.runLater to do.

    But the GUI crashes at the start (does not display anything) for the first 5 seconds (sleep time) changes and shows.

    I want to display the GUI at first, and then after 5 seconds the GUI should be updated with the message, but with the code it hangs just first and screens below everything after 5 seconds.

    Here sampleGUI is a an application javafx with inside text fields.

    + / public class StartGame extends Application {+
    +@Override+
    + public void start (steps) riser Exception {+
    final sampleGUI gui = new sampeGUI();
    GUI. Start (training);

    + Platform.runLater (new Runnable() {+)
    +@Override+
    + public void run() {+
    + try {+
    System.out.println ("sleep now...");
    Thread.Sleep (5000);
    System.out.println ("sleep above!");
    gui.updateText ("new message");
    +} catch (InterruptedException ex) {+
    System.out.println ("exception" ex); +
    +}+
    +}+
    +});+
    +}+
    +}+
    Platform.runLater(new Runnable() {
      @Override
      public void run() {
       // ...
      }
    });
    

    causes the run method of the executable to run on the Thread of the FX Application. Since you put Thread.sleep (5000) inside the run method of your executable, sleep occurs on the Thread of the FX Application.

    The call to runLater (...) can be called from any thread, including the Thread of Application FX.

    So, if you are not in the FX Application thread, you want to:

    // any long-running task, for example
    System.out.println("Sleeping now");
    Thread.sleep(5000);
    System.out.println("Sleep over");
    Platform.runLater(new Runnable() {
      @Override
      public void run() {
        // update UI:
        gui.updateText("New Message");
      }
    });
    

    If you are on the thread of the Application of FX, which is the case in your Application.start (...) method, you must create a new thread to run your code of long duration. You can do this "manually", creating a Thread and a workable for it to run, but it is probably best to use the simultaneity of JavaFX API, which has many hooks useful for updating the user interface on the Thread of the FX Application.

    In this case, the code would look like this:

    public class StartGame extends Application {
      @Override
      public void start(Stage stage) throws Exception {
        final SampleGUI gui = new SampleGUI();
        gui.start();
        final Task waitingTask = new Task() {
          @Override
          public String call() throws Exception {
            System.out.println("Sleeping");
            Thread.sleep(5000);
            System.out.println("Sleep over!");
            return "New Message" ;
          }
        };
    
        waitingTask.setOnSucceeded(new EventHandler() {
          @Override
          public void handle(WorkerStateEvent event) {
            gui.updateMessage(waitingTask.getValue());
          }
        });
    
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.submit(waitingTask);
      }
    }
    

    There are (probably of dozens of) other ways to use a task to do. See the API documentation [url http://docs.oracle.com/javafx/2/api/javafx/concurrent/Task.html] for the task for more information.

Maybe you are looking for