Call MainScreen.invalidate () in thread

Hi guys.

This article is about: how - to upgrade a screen on the main event Thread

If you call the MainScreen.invalidate () method on the thread main event, you can use

UiApplication.getUiApplication () .invokeLater (new Runnable() {}
public void run()
{
Make changes to screen here.

Invalidate() call on your display requires painting
method to call.
screenName.invalidate ();
}
});

In my case, I use thread to change the screen appearance.

So, I'm not sure who use UiApplication.getUiApplication () .invokeLater

on actual thread.

Do you have any suggestions here?

I have to UiApplication.getUiApplication (.invokeLater) / invokeAndWait?

Or don't need?

Thanks in advance.

You can call invalidate() without holding the thread of events.  So, if that's all you do, then just call invalidate().

If you also update some user interface components (for example, adding text to a field of text, then you must do so while holding the thread of events.  The best way to do this is the method explained in the article, and I recommend that you, unless you have good reason to do something else.

If you need to ensure that the update has occurred, then use invokeAndWait, but I recommend you do not do this if you can.

PS. Bravo for the article!

Tags: BlackBerry Developers

Similar Questions

  • MainScreen.invalidate () seems to work very well, but not ObjectListField.invalidate)

    Hi, I hope just fast - is there a quirk with ObjectListField.invalidate () and invalidate (rowindex)?

    See you soon

    J

    Hey. Of course the Invalidate() rebuild fields, he redraws just them. The icon of hasbeenread had to be changed to drawlistrow, not disabling.

    J

  • Threading and reuse of the node to call using reference of buffers (of the required adhesive tape)

    I tried to get the following information in the public domain for years and now that I have the answers, I'll share with those who might be interested.

    Caveat!

    Wrap your head in tape before reading just for the sake of security.

    My two questions were;

    (1) may LV re - use tampons of VI calling when you use VI serve call by reference?

    (2) is used when the use of call by reference UI thread?

    1 when you call a VI using the call through the reference node, the data in the pane of the copied or is node connector - this online as it would be with a Subvi properly implemented?

    Short answer: it's somewhere between the two.

    Long answer:

    The compiler does not know what will be called VI, but there a hint:

    the reference connected to the node of the call by reference. He uses to get the 'Prototype' for the call. Therefore, for optimal performance, use a prototype that has the same 'characteristics placeness' as it is called VI. That said, users don't know what are the "characteristics of the placeness.

    Before getting into the details, I will say that the overhead of these copies should not matter much unless it's a large data structure (a table with lots of items.) or a cluster/class with many fields or containing large networks etc..

    Example 1:

    If the prototype does not change the data, then the compiler assumes that the crux of the call by reference will not alter the data. However, at runtime, a check is made to see if the real called VI will modify the data. If Yes, then a copy is made and past so that the original data can be modified.

    Example 2:

    If the prototype contains an entry that is wired through an exit so that both input and output terminals can use the same buffer memory, but running an audit determines that the real called entry and exit VI do not share a buffer, then a copy will be made from output of the actual call to the original screws (combined input and output) buffer.

    I should also mention that, even with this behavior "are trying to get along with the prototype", it is not always possible to obtain good performance as a Subvi ordinary call. For example, if you have a situation where the prototype does not change the data and passes it through to an exit and then the compiler must assume that the data is changed (because, as in example 2, there are screws that may change even if the called real VI is not).

    And there are a few caveats:

    (1) this behavior "using a prototype" was new for 2009. Before that, we used a method more naïve data of passage that took all the entries will be changed and no outputs don't share a buffer with an entry.

    (2) this behavior can be changed in future versions, if we find additional optimizations.

    (3) this behavior is the same that we use for the dynamic distribution live (when you use the classes in LV)

    (4) If you want to create a VI can be used as a prototype, you can use the features of the Structure in Place to control the "characteristics of the placeness', namely the element nodes in and out of the border, the function"Mark as modifier"border nodes (note the pencil icon on the item), and the node always one copy.

    (5) the prototype is only the first reference ever connected to the node of the call by reference. So if you make a new prototype VI, you can just make a reference out of it plug into the crux of the call by reference. I suggest to remove the node from the call by reference and file a new.

    (6) for remote calls, we still "making copies" by transmitting data over a network.

    I hope that this helps, if you want information/clarification, so feel free to ask.

    2 - is the call made by the reference to run in the user interface thread node? If the call is made by a remote machine via ethernet, thread that host (the computer that makes the call by reference) runs on and thread that executes the target (the machine that contains the file VI) on?

    In the case of premises, the appeal made by the reference node does not require the user interface thread and may work in some thread the VI wants to run in.

    When you call a remote VI, the appeal made by the reference node uses the UI thread (detailed below) on both the client and the server.

    The client uses the UI thread to send the request to the server and there still when the response comes back. The user interface thread is not blocked during the time between the two.

    The server receives the TCP message in the UI thread, and then starts the call to the UI thread. The server also uses the user interface thread to send the response to the client. The user interface thread is not blocked on the server during execution of the VI.

    I hope that people find it when they need it!

    Ben


  • Call any thread DLLs the application crashes

    I have a built in 2015-labview application that acquires spectra of 6 spectrometers via an external dll. The dll triggers an event in labview when data is ready to be pulled from the spectrometers. Since this event, I am running a reentry no void / vi which contains a node function to retrieve the data, that are configured to run in any thread, as it gives a drastic improvement of performance as apposed to run in the UI thread.

    However this can slow down the application crash with a message from windows like the following journal:

    Name of the failing application: axiom 2.0.exe, version: 1.0.0.82, time stamp: 0x5581a6b7
    The failed module name: lvrt.dll, version: 15.0.0.4024, time stamp: 0x5581ac03
    Exception code: 0xc0000005
    Offset: 0x0000000000bec7c0
    ID of the process failed: 0x15c0
    Start time of application vulnerabilities: 0x01d11e6face9febd
    The failing application path: C:\Axiom 2.0\builds\Axiom 2.0\Axiom 2.0.exe
    Path of the failing module: C:\Program NIUninstaller Instruments\Shared\LabVIEW Run-Time\2015\lvrt.dll
    Report ID: 7d4ef3a8-8a91-11e5-94e9-90b11c894ef8

    I don't know if the dll is said to be thread safe or not. Also I do not understand how this causes a problem anyway since it is the only node that accesses the dll at the time, and each of the 6 spectrometers are interviewed in order?

    Is there anyway that I can still enjoy the benefits that the call of any thread dll provides without causing my application crash.

    An example of the increase in performance, it's that I can query the spectrometer from 6 to 70-80 Hz when configured to run in any thread, as opposed to a simple 10 Hz when the Run value in the UI thread.

    Thank you

    Jimmy01 wrote:

    I don't know if the dll is said to be thread safe or not. Also I do not understand how this causes a problem anyway since it is the only node that accesses the dll at the time, and each of the 6 spectrometers are interviewed in order?

    Is there anyway that I can still enjoy the benefits that the call of any thread dll provides without causing my application crash.

    Looks like that the DLL is not thread-safe. If you do not run in the UI thread, there is no guarantee that the DLL will be always called from the same thread, even if you only call it in one no reentrante Subvi. By default, LabVIEW allocates multiple threads by the enforcement system, with the exception of the user interface. If the DLL stores certain information of one call to the other, this context can be lost when run in a different thread.

    Here's a thread that provides two possible solutions; a wrapper DLL is required, use the other the utility 'threadconfig' (or the corresponding INI file settings) to force a subsystem of a thread executing unique http://forums.ni.com/t5/LabVIEW/Force-DLLs-to-tun-in-the-same-thread-expect-the-UI-Thread/td-p/11438...

    Another option would be to put the call to the DLL in a timed loop that runs constantly, and you can use a queue or the notifier to pass data to. A timed loop runs in a single dedicated thread, so I think it will work.

  • ERROR, called from the thread NON-INTERFACE QThread

    I am trying to load an image using QtConcurrent:map at the same time and I received this error.

    WARNING: ApplicationPrivate::context: ERROR called NON-INTERFACE QThread thread (0xf9ff68, name = "thread (pooled)" ")
    Fatal: ApplicationPrivate::context: method called from the UI thread

    I simplified the code as follows:

    imagescaler::queuescaling{
    ..    mimageScaling = new QFutureWatcher(this);
    mimageScaling->setFuture(QtConcurrent::mapped(mImageList, scaledImage));
    ..
    }
    
    Image scaledImage(QString file_name) {
       QImage qImage;
       bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied, qImage.width(),
      qImage.height());  // causes error
      return imageData;
    }
    

    Anyone know what the problem is or how to work around?

    Thanks for point out the bb:ImageData.  Never noticed the incompatibility.  Image converts ImageData to initialization, so it does not create an error.  However, if I return an ImageData rather than the Image it does not crash.  I then simply convert ImageData of Image in the UI thread and it works very well.

    I'm curious to know why I can return a blank image and I can return an imageData, but I can't go back an Image that's been converted from ImageData.  Do not understand what can or cannot be done outside the UI thread.

  • Why almost all javafx methods must be called from the thread of the application?

    I have a pretty big 3D scene that is refreshed every few seconds.

    It takes a while to update the scene, and I wanted to do it in a background thread.

    Problem is that almost every approach I take requires the application-fx thread.

    Now, I understand that change the UI itself must be called in the application thread, so I tried a different approach:

    Create a new group, add all the nodes (which takes the greatest amount of time) and update the component root of the view with the new group.

    I assumed that only the last party required the application thread, but alas this was not the case.

    group.getChildren () .add also requires that the thread of the application. Why?

    node.setLayoutX () also requires that the thread of the application. Why?

    It is a new set of nodes that are not visible and groups yet, so why can't do this in a background thread?

    The reasons of principle (I think) that JavaFX is mainly a single toolbox threaded are described in:

    https://weblogs.Java.net/blog/2004/10/19/multithreaded-toolkits-failed-dream

    That said, if you manipulate objects that are not part of an active scene, then it should work.  The dream that failed has what to do with the components who participate actively in the molten, interactive GUI.  If you're interacting with only the components out of the screen, then it (should be) without issue.

    Please, create and post an example minimum, executable that replicates the question.

    (Please ensure that the example is minimal and executable).

    In addition, what is the cause as your application "takes some time to update the scene?  Computers are today quite incredibly fast.  Of course, there are valid reasons for some things take time, I wonder what these are in your case.  What is the time?  If your executable example can include something reasonably representative of what you're done which shows something that will take "some time", would be great.

    What you have described so far, I feel that, even if there is no problems with threads, your proposed approach would not fix your performance problem.

  • Thread synchronization

    Hi all

    I don't really know how to work the Blackberry UI thread!

    I have the function run a thread in which I make my travel manager. After the move is completed I want to set the focus on the Manager, but is not update:

    first call this function

    later, calling animateProfile() - thread function

    and finally call animCompleted() (who must be the focus on manager)

    public void performAction() {}
    If (null == profileClick) {}
    If (null! = listener) {}
    listener.performAction ();
    }
    initProfile();
    animateProfile();
    animCompleted();
    } else {}
    Reset();
    }
    }

    private synchronized void animateProfile() {}
    Blade wire = new Thread() {}
    public void run() {}
    int count = 0;
    int height = profileClick.getPreferredHeight () + 4;
    While (count< height)="">
    profileClick.moveScreen (0, count);
    Invalidate();
    try {}
    Thread.Sleep (10);
    } catch (InterruptedException e) {}
    e.printStackTrace ();
    }
    Count += 8;
    }
    animCompleted = true;
    }
    };
    Slide.Start ();
    }

    private void animCompleted() {}
    If {(animCompleted)
    profileClick.setFocus ();
    }
    }

    Any help?

    Greetings.

    As arkadyz says, in your call to animCompleted() is run, if the variable animCompleted Boolean is false, that it does not lead us to know.

    Your call to animCompleted() must be made since your overloaded runs your slide wire internal class method. In addition, you must call it in such way that the thread of events that changes the user interface and any other foreign thread.

    To achieve this, you must do something like this:

    private synchronized void animateProfile() {
            Thread slide = new Thread() {
                public void run() {
                    int count = 0;
                    int height = profileClick.getPreferredHeight() + 4;
                    while (count < height) {
                        synchronized (UiApplication.getEventLock()) {
                            profileClick.moveScreen(0, count);
                            invalidate();
                        }
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        count += 8;
                    }
                    UiApplication.getUiApplication().invokeLater(new Runnable(){
                        public void run() {
                            profileClick.setFocus();
                        }
    
                    });
                }
            };
            slide.start();
    }
    

    Let me know how helpful it is for you, please. Good luck.

  • How to get the phone in ongoing call screen

    It is a follow-up on the menu of the phone not shown thread.

    I checked with the KB and found an interesting topic: How - to upgrade a screen on the main event Thread

    My original question (as can be seen in the thread has already been mentioned) was to know how to draw something on the screen of the phone.

    Example:

    (1) a user accepts a call.

    (2) my application implements PhoneListener and in callConnected() just draws a picture on the top of the phone application

    (3) all the features of the phone (menu of the phone for example) are preserved.

    The article mentioned shows that it is possible to draw something on a screen.

    How can I get an instance of the phone screen?

    Here is my proposal (but it does not work):

    public void callConnected(int arg0){ UiApplication.getUiApplication().invokeLater(new Runnable()        {
    
                public void run()            {                Screen screenName = UiApplication.getUiApplication().getActiveScreen();                //Perform screen changes here.                Graphics g = screenName.getGraphics();                g.setColor(0xFF8080);                g.fillRect(10, 10, 100, 100);                //Calling invalidate() on your screen forces the paint                 //method to be called.                 screenName.invalidate();            }        }); }
    

    How to make the getUiApplication() to pick up the phone?

    Do you ever feel like you're talking to yourself ?

    That's what I had:

    //Calling invalidate() on your screen forces the paint                 //method to be called.                 screenName.updateDisplay();                //screenName.doPaint();                //screenName.invalidate();
    

    Why the work of updateDisplay doPaint (as well as his brothers and sisters invalidate()) does not work?

    But, alas, my efforts have been in vain.

    The 'red square' disappears when something is painted on them -ruins it a bit.

    So, I guess, my quest continues.

    Someone has an idea how draw a persistent image on the VoiceApp and always to enable all the features of VoiceApp (menu, for example)?

  • [HELP] Call library function node...

    I have a DLL that has a function as follows:

    int GetMessageNameNumber (char * messageName [], const int MessageNumber);

     

    The function is used thus:

    char * MessageName = NULL;
    int MessageNumber = 0;
    ...

    error = HL1553API_GetMessageNumberName (& MessageName, MessageNumber);

    MessageName will contain the name of the message as a string.

    I saw the Devils own job trying to wrap this in a Labview module.  I have a knot of library function to call the above function, but I'm not sure what to set the parameter "MessageName" also!  I tried array of integers 8 signed bits, adapted to the Type of pointer to data in the table and then passed in an array of strings.  Whatever I do translates into LabView crash.  I know HL1553API_GetMessageNumberName works, because if I call it directly in TestStand it works fine.  I need LabView well!

    Any ideas?

    C a pointer to a string or an array of strings are completely ambiguous.

    char * something = char * something [].

    You can't tell the two apart from the syntax, but only from the documentation or an example of how the function is called. A C compiler treats the equal in terms of access (but a C++ compiler will do a syntactic differentiation when code syntax checking, with the possible result compile warnings when you are prompted to use a sufficiently high level of warning).

    The example shows that it is not a string array gets allocated by the caller and passed to the function, but a string pointer that is passed by reference. So the function will allocate a pointer and return it (a very atypical C practice at least for strings). This automatically raises the question when and how this pointer will be released? The documentation for this function should document the call from Manager memory allows to allocate this pointer and also point to the function to call to release. Ideally the library (DLL) provides an exported function for this purpose.

    Assume that everything I spoke so far is clear and available you need to cheat a bit LabVIEW. You need to configer a pointer size whole that is passed by reference. Now this whole in the diagram IS actually your channel. If you only need to pass this pointer to other library functions call that you're already doing. Otherwise if you need access to the contents of this string from the diagram LabVIEW, you will need to copy the information from this string to a real string of LabVIEW pointer.

    One way to do that is to use the export of the MoveBlock() C function that LabVIEW exports itself. I have explained this several times here on this forum and the MoveBlock research will no doubt find out these positions.

    Another slightly better way is to use the LStrPrintf() function which also exports of LabVIEW. To do this, you configure a library function call as follows:

    Library name: LabVIEW

    Function name: LStrPrintf

    Calling Convention: C

    Thread: both are possible, but the function is thread safe, so just use environment

    return parameter: int32 (there is a possible LabVIEW Manager error code)

    1st parameter: handle string of LabVIEW, passed by value

    parameter 2: C string pointer

    3rd parameter: integer pointer size, passed by valu

    Wire an empty string in the first parameter constant.

    Wire a constant containing the text '%s' without the quotes on the 2nd.

    The pointer to your thread on the 3rd string

    The function will return 0 as a return value and the content of the string on the side of the exit of the 1st parameter or a zero value indicating that a mistake to return back.

  • Two parallel executions, calling a DLL function

    Hello

    Since this test takes about 6 hours to test my USE, I plan to use the parallel model to test 2 UUT at the same time in parallel.

    I implement the test code as a DLL of CVI.

    However, to my surprise, it seems that the steps that call a DLL function actually traveled in one series, not in parallel:

    Test 2 power outlets if one enters and executes a DLL works, the other waits for the first to complete its operation and return. While the other runs on the same copy of the DLL, so that the DLL global variables are actually shared between executions.

    So if a DLL will take 5 minutes to complete, two executions in the running at the same time take 10 minutes. This isn't a running in parallel in every way.

    What I want and expect also TestStand, was to completely isolate the copies of these two executions DLL such as test two casings could run at the same time the same DLL function by arbitrary executiong their copy of the function, completely isolated from one another.

    So they separated globals, discussions, etc., and two parallel jacks take 5 minutes to run a step, instead of 10.

    Such a scenario is possible?

    If not, how can I use my test in parallel (in truly parallel) when the use of 2-socket test?

    (1) Yes, he'll call the multiple executions in TestStand calling into the same dll in memory the same copy of this DLL. Thus dll called in this way must be thread-safe (that is written in a way that is safe for multiple threads running the code at the same time). This means usually avoiding the use of global variables among other things. Instead, you can store the thread shows in local variables within your sequence and pass it in the dll as a parameter as needed. Keep in mind all the DLLs your dll calls must also be thread-safe or you need to synchronize calls in other DLLs with locks or other synchronization primitives.

    1 (b) even if your dll are not thread-safe, you might still be able to get some benefits from parallel execution using the type of automatic planning step and split your sequence in independent sections, which can be performed in an order any. What it will do is allow you to run Test a socket A and B Test to another socket in parallel, and then once they are then perhaps test B will take place on one and test one run on the other. In this way, as long as each test is independent of the other you can safely run them in parallel at the same time even if it is not possible to run the same test in parallel at the same time (that is, if you can not run test on two Sockets at the same time, you might still be able to get an advantage of parallelism by running the Test B in one take during the tests in the other. See the online help for the type of step in autoscheduling for more details).

    (2) taken executions (and all executions of TestStand really) are threads separated within the same process. Since they are in the same process, the global variables in the dll are essentially shared between them. TestStand Station globals are also shared between them. TestStand Globals file, however, are not shared between runs (each run gets its own copy) unless you enable the setting in the movie file properties dialog box.

    (3) course, using index as a way to distinguish data access are perfectly valid. Just be careful that what each thread does not affect data that other threads have access. For example, if you have a global network with 2 elements, one for each grip test, you can use safely the decision-making of index in the table and in this way are not sharing data between threads even if you use a global variable, but the table should be made from the outset before start running threads , or it must be synchronized in some way, otherwise it is possible to have a thread tries to access the data, while the other thread is created. Basically, you need to make sure that if you use global data which the creation/deletion, modification and access in a thread does not affect the global data that the other thread use anyway in or we must protect these creation/deletion, modification and access to global data with locks, mutex or critical sections.

    Hope this helps,

    -Doug

  • several tasks in multi threads

    I have an application that must be able to go out and capture of several materials OR simultaneously.

    I coded it so that each task nidaq contains only the ports of capture for a single device or output ports for one device. That is, if I use two DevA and DevB devices to capture and output I'l have four tasks capture devA, capture devB, output and output devB devA.

    Currently each task runs in its own thread, task is called only when all threads are ready to move on (each thread starts its own task).  AO1 is loop back to AI0 on devA so that the result is captured by the same device.

    Unfortunately repeated screenshots show a variable phase shift in the AI0. The captured wave is often shifted left or right by as much as 1000 samples @48 kHz.

    This problem could be alleviated by the achieve the capture and playback across all channels and devices in a single thread (sequential entry and exit) or random moving would still exist?

    Basically, I want to perform the exact sample input and output.

    If you are interested in the synchronization of multiple devices USB-4431, then you need to use a different type of device at the exit of a trigger signal.

    Although the USB-4431 e/s digital, they can only be used to import triggers start or reference (see page 9 of the following manual):
    http://www.NI.com/PDF/manuals/372485e.PDF

    Because of this limitation, you will need to use an external trigger source to synchronize multiple devices USB-4431.

    For large applications of synchronization, I recommend looking at the SMU system. Complete modules NI-SMU-4499 SMU chassis can support synchronization of up to 272 channels. More information about the synchronization is located in the Developer Zone article:
    http://www.NI.com/white-paper/11369/en/

  • thread different not mobile Panel

    I () will have applications of measure which changes, sends a bitmap image in its Panel to a network Variable.

    I have a player that connects to the network variable. It was a reminder that fires on an update of the value or the State. Because the size of the bitmap is variable, recall retrieves the size of the bitmap, adapts to the size of the Group and its control of the single photo and copy the bitmap to the image control.

    It seems as if the reminder runs in the same thread that is different from the hand. The Panel with image control is to build (using NewPanel) since even when updated its tire recall the first time. It is a toplevel with Windows minimize/maximize/close panel. A hidden control is used to connect a callback to the closing of Windows. Resizing and display once and update the network variable works very well. However, I'm not able to move the Panel by picking up with the mouse. (During recovery mode debugging, parameters, GetPanelAttribute reports that it is mobile).  I'm not able to close the cover with the closing of Windows.

    I built any additional features (such as the management of Windows messages) for this Panel. I need only as an indicator to display a bitmap image.

    What should I do to make it a chattel or able to close?

    Depending on how you connect to the network variable, the function is actually called in a separate thread: this document examines all available methods to read of an NV and lists the features for each of them, execution of the thread includng.

    To resolve this problem, you can modify your application so that the Panel is created in the main thread or in an explicit Candran, which calls ProcessSystemEvents () so that the user is properly managed. The drive function could then retrieve information from the NV, decode and send all data to this thread via a thread safe queue or some other method.

  • Comparison of the data in the new thread in parallel with the hand

    I have a file of main sequence. Overall, I got a call from sequence that initializes an oscilloscope and returns to the hand. Next main action, I have the user turn on power supply and confirm with a popup message. My question is now, I need to create a new thread before action "light food" for the oscilloscope intercepts all overloads and continues to record. So if this is the case, what I'm trying to do is:

    Call sequence Initialize oscilloscope

    Call sequence oscilloscope Fetch

    Message Popup, power supply turns on, confirm with "OK".

    -Now, since the user disabled on food, I need compare all data, even while the user turns on the power and clicks "OK" and after.

    So, I need an oscilloscope running in parallel and by comparing data during execution of the main sequence. Any help would be appreciated.

    The type of call sequence step has an option of a sequence of sub in a new thread.

    Call sequence Initialize oscilloscope

    Sequence oscilloscope Fetch call (call in a new thread and it will acquire signals until it gets a signal to stop to the main following)

    Message Popup, power supply turns on, confirm with "OK".

    Delay if necessary

    Set the signal to stop the thread close.

    I hope this helps.

  • Function calls multithreaded suddenly causing blockages

    I'm having a problem with function calls from multiple threads. There are two threads that everyone calls a function called save_program, including a DDCChannelHandleGroup and and a certain structure "show pulse" moved. The problem I have is that after that I called him save_program of one of the sons, it crashes when I try to call from the other thread. There are three contexts for this - two in the main thread and the other in the thread of data acquisition.

    If I call the save_program of one of the contexts in the main thread, the program crashes when I try to call it in the thread for the acquisition of data and vice versa. No problem since the two contexts in the same thread. I put a breakpoint in the function call and the first part of the executable code in save_program (declaration of variable initialized to NULL), and the program freezes between these two breakpoints. I checked and always executed entirely complete in each of the threads AND the call of CmtExitThreadPoolThread() also runs very well. I also locked up all instances of save_program in CmtGetLock/CmtReleaseLock calls without success. Oddly, these calls used to cause no problems with the exact configuration of multithreading even. I don't know what has changed.

    Hi PaulGanssle,

    It is very possible that you have already encountered a problem experienced in LabWindows/CVI where transactions must be completed before calling SaveFile.  I have included a link below that talks a little more about this problem.

    http://zone.NI.com/DevZone/CDA/tut/p/ID/12323#281013_by_Category

    It is a question that has been reported and is managed by R & D.  From now on, it is not a fix available but I hope we can find a work around that will work for your application.

    Please let me know if you have any other questions.

    Kind regards

    Kyle S

  • 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.

Maybe you are looking for