How to call a sequence in a new thread from C++ dll
Here is what I am trying to do:
I implemented a dll that monitors network traffic, and it also supports message handlers that can be triggered when a specific message has been received. Essentially the receipt of a message is like an event causing additional code to be executed. What I need to do is have the message handler in the dll call/execute a sequence (either is the same sequence file that originally called the dll, or in a different sequence file). Also I want the sequence to be executed within the same execution object for the purpose of result collection and report generation. I am expecting the dll to have to launch a new thread to call a sequence because of the asynchronous nature of the message received event.
There are easier ways to achieve the same result, but one of my goals is to make it easy for a test developer to configure a message handler, by having only one step in their sequence to configure the message handler. I want the rest to be transparent to the user.
I am unsure about how to implement this feature, so I am asking for any examples, ideas, comments before I start trying things out.
Assuming that I understand your question correctly, it would seem to be the best way to do this would be to pass the Execution object to the DLL (either through a direct pass of the Execution object or passing the sequence context, from which you can get the Execution). Then simply call Execution.NewThread, specifying the SequenceFile object (accessible from Engine.GetSequenceFileEx) and then passing the Thread object out as an output. Your sequence file in which your DLL is called could then simply have a Wait step which is configured to wait on that Thread object. What happens in this case is that the results are collected for that thread (which is being executed asynchronously) and returned as the results for the Wait step.
Although you are probably not using LabVIEW, I have attached an example of this in LabVIEW that might be helpful just for seeing the flow.
Thanks,
Andy McRorie
NI R&D
Attachments:
thread_test.seq 32 KB
testthread.vi 19 KB
Similar Messages
-
Calling a sequence in a new thread with different values
I have a sequence that I want to call that runs in parallel (seperate thread). The question I have is that I want to run this sequence from a lot of different places, but with different values of the variables going into the steps inside the sequence.
If I change the values inside the sequence (running on seperate thread), then I will have to duplicate this sequence over and over. What I really want to be able to do is run a step in a seperate thread, and not wait for it to complete. Is this possible? Or a method of passing step values into a seperate thread. I don't want to use globals unless I really have to.Hi ADL,
I have attached an example which I hope will illustrate an answer to your question.
Regards
Ray Farmer
Regards
Ray Farmer
Attachments:
Sequence_File.seq 34 KB -
How to call a transaction (in a new session) from a program
Hi ,
I need to call a transaction from my report on the click of a button in toolbar.
But the transaction should open in a new session.
This is the code that i have written, MM03 is getting opened in the same session.
call transaction 'MM03' and skip first screen.
Hope that my question is clear.
Thanking you in advance..
Shankarcheck this
<b>CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'TEST'
DESTINATION 'NONE'
EXPORTING
TCODE = 'SM59'
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT
SYSTEM_FAILURE = 2 MESSAGE MSG_TEXT.
IF SY-SUBRC NE 0.
WRITE: MSG_TEXT.
ELSE.
WRITE: 'O.K.'.
ENDIF.</b>
<b>u can avoid such errors thru this FM
check FI_DUPLICATE_INVOICE_SHOW program for sample code.</b>
regards
Prabhu
Message was edited by: Prabhu Peram -
Hi,
I am including steps inside a sequence which calls sub sequences in a new thread. After calling each sub sequence in a new thread, I am putting Wait step which is configured to wait for the respective sub seueqnce to complete its execution. When I include these steps (call a subsequence in a new thread and then configuring wait to complete it) once, it executes properly but when I includes these steps twice, I get debug warning when I close Teststand sequence editor. Due to this behaviour, when I run this sequence through operator interface (Simple OI), I get run time error R6025.
I checked if there is any object reference which might not be released, but could not figure it out here. Please see attached sequence and the debug warning message.
Used version: Teststand 4.0.1, LabVIEW 8.5, Windows XP
Kindly help.
Thanks in advance,
Nirmal
Attachments:
Sequence_new_thread2.seq 37 KB
Debug Warning2.JPG 34 KBHi Nirmal,
Thanks for the detailed instructions. I tried exactly what you said and I still do not see the leak. The problem is likely specific to something customized on that machine or in the very least does not happen every time or on all machines. I'd recommend trying to narrow down by eliminating the possibility of an unintended customization. If you can try installing a clean install of teststand on a clean machine and see if you can still reproduce the problem then that would help narrow things down a little. If you can't reproduce it on a clean install on a clean machine then I'd start looking at what's different on the machine you can reproduce it on. You could remove your config files to eliminate customizations to settings such as search directories. You could remove files from your components\User directory to eliminate the possibility of using those. Just a few ideas. Other people might have some other ones.
-Doug -
I want to know how to call navigate to page in new window.
Hi,
I want to know how to call navigate to page in new window.
Following is the code which i am using on Event OnInputProcessing.
navigation->goto_page( 'index.htm' ).
From the above code i am able to open the index.htm in the same window.
but I need the index.htm in the new window.
Please suggest
Thanks in advance,
Nilesh LabdeThanks ,
I was able to find the navigatiion tab, But after entering the The Form name in that TAB, Still the New Page opens in ths SAME window.
Following is the Code written on the Eevent--> OnInputProcessing
navigation->next_page( 'NEXT' ).
In the Navigation TAB
Start Navigation Request Target
Sales_Person.htm NEXT index.htm
Please suggest.
Thanks in advance,
Nilesh Labde -
How do I install Acrobat on my new PC from my old PC
How do I install Acrobat on my new PC from my old PC
You don't install from your old PC. You install from whatever resource was used to install it on your old PC.
-
How to call a class that extends a frame from a panel ?
How to call a class that extends a frame from a panel ?
I am trying to create an application say "Videoshow"
Videoshow has a panel which in turn consists of 2 components : 1]a textarea( to show the contents of a page) and 2] a mediaclip(to show the video).
Now I have an application "MediaApplication"(to show the videoclip) which extends Frame (Code from Java 2 Unleashed, Chap 21). I want to show this MediaApplication in Component 2 of the above panel. But when I do this, I only see the MediaApplication frame instead of the whole SlideShow.
I want to do something likethis.
VideoShow :
|---------------------------------|-------------------|
| |
| (Comp 1) | (Comp 2)
| TEXTAREA | Video Clip
| |(MediaApp entends Frame)
|---------------------------------|-------------------|
What is the best way to achieve this ? Also which component can I use to show the videoclip ?im not familiar with the code you mention from Java 2 Unleashed, but your best bet is to read up on Swing a bit - so you get an idea of how Swing containers and components work - then im sure you'll find a solution to your problems. Then if you encounter any difficulties whilst your attempting to do that, post your code in the Swing forum and im sure someone will help you.
-
How to call java method having array as argument from c++ ?
Hello sir,
how to call java method having array as arguments from c++;
here is java code which is called from c++
class PQR {
public void xyz(int[] ia) {
System.out.println("hi");
for (int i = 0; i < ia.length; i++)
System.out.println(ia);
suppose all jvm invocation is done...For someone well versed in java, C++ and JNI although tedious that should be obvious.
For someone not well versed in all three it is going to be very difficult.
Even for someone that does have knowledge in all of those areas coming up with a C++ interface that reflects that functionality in a dynamic way such that anyone is will to use it is going to be quite an adventure.
At any rate to start building it you do exactly the same thing that you would in java.
1. Extract everything in the jar via the zip package
2. For each found instance extract all of the methods, return types, parameters, etc and build a description tree for each class.
Doing all of that in C++ is going to take a LOT of code. If someone wanted an estimate from me it would take me 6 months to do it. And before I would even attempt it I would get them to explain to me in detail exactly how they thought they were going to use it when I was done because I can't see any reasonable way to do that.
I left out the description tree itself. I suppose you could duplicate the entire reflection api in C++.
Now perhaps if it was much, much more constrained, like to only those classes that implement a single interface then that would be more reasonable. -
How to transfer my certificate to this new account from old acount
how to transfer my certificate to this new account from old acount
You don't. Registration is a one time thing that you do the first time you install an application. Once registered it does not need to be done again.
You should see if yoiu can have the activations reset before you try installing on a new machine so that you still have the two activations that are available to you. If not, you should still have an activation available for use with the new installation.
To reset activations contact Adobe Support and ask them to reset your activations.... For the link below click the Still Need Help? option in the blue area at the bottom and choose the chat option...
Serial number and activation chat support (non-CC)
http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )
To get it working on the new machine you just install and activate using the serial number you should already have. -
How can I move CC to a new PC, from one I am returning to our asset team?
I have CC installed on two PCs. So how can I move CC to a new PC, from one I am returning to our asset team?
HowardYou only need to sign out of it on the machine you wish to not use it on anymore. After that, if you choose to you can uninstall it, but it is not necessary in terms of the software... maybe your asset team has issue with it remaining though.
To get it on the new machine just install the same way you did for any others... install the Cloud manager, sign in, install the applications. -
Calling a delegate on the UI thread from a work thread inside a child class.
Hi All,
I've run into a snag developing a WPF multithreaded app where I need to call a method on the UI thread from my work thread, where the work thread is running a different class.
Currently I am trying to use a delegate and an event in the 2nd class to call a method in the 1st class on the UI thread. This so far is not working as because the 2nd class is running in its own thread, it causes a runtime error when attempting to call
the event.
I've seen lots of solutions referring to using the dispatcher to solve this by invoking the code, however my work thread is running a different class than my UI thread, so it seems the dispatcher is not available?
Below is as simplified an example as I can make of what I am trying to achieve. Currently the below code results in a "The calling thread cannot access this object because a different thread owns it." exception at runtime.
The XAML side of this just produces a button connected to startThread2_Click() and a label which is then intended to be updated by the 2nd thread calling the updateLabelThreaded() function in the first thread when the button is clicked.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Threading;
namespace multithreadtest
public delegate void runInParent();
public partial class MainWindow : Window
public MainWindow()
InitializeComponent();
threadUpdateLabel.Content = "Thread 1";
private void startThread2_Click(object sender, RoutedEventArgs e)
thread2Class _Thread2 = new thread2Class();
_Thread2.runInParentEvent += new runInParent(updateLabelThreaded);
Thread thread = new Thread(new ThreadStart(_Thread2.threadedTestFunction));
thread.Start();
public void updateLabelThreaded()
threadUpdateLabel.Content = "Thread 2 called me!";
public class thread2Class
public event runInParent runInParentEvent;
public void threadedTestFunction()
if (runInParentEvent != null)
runInParentEvent();
I'm unfortunately not very experienced with c# so I may well be going the complete wrong way about what I'm trying to do. In the larger application I am writing, fundamentally I just need to be able to call a codeblock in the UI thread when I'm in a different
class on another thread (I am updating many different items on the UI thread when the work thread has performed certain steps, so ideally I want to keep as much UI code as possible out of the work thread. The work threads logic is also rather complicated as
I am working with both a webAPI and a MySQL server, so keeping it all in its own class would be ideal)
If a more thorough explanation of what I am trying to achieve would help please let me know.
Any help with either solving the above problem, or suggestions for alternative ways I could get the class in the UI thread to do something when prompted by the 2nd class in the 2nd thread would be appreciated.
Thanks :)If I follow the explanation, I think you can use MVVM Light messenger.
You can install it using NuGet.
Search on mvvm light libraries only.
You right click solution in solution explorer and choose manage nugget...
So long as you're not accessing ui stuff on these other threads.
using GalaSoft.MvvmLight.Messaging;
namespace wpf_Tester
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public MainWindow()
InitializeComponent();
Messenger.Default.Register<String>(this, (action) => ReceiveString(action));
private void ReceiveString(string msg)
MessageBox.Show(msg);
Dispatcher.BeginInvoke((Action)delegate()
tb.Text = msg;
private void Button_Click(object sender, RoutedEventArgs e)
Task.Factory.StartNew(() => {
Messenger.Default.Send<String>("Hello World");
What the above does is start up a new thread - that startnew does that.
It sends of message of type string which the main window has subscribed to....it gets that and puts up a message box.
The message is sent from the window to the window in that but this will work across any classes in a solution.
Note that the receive acts on whichever thread the message is sent from.
I would usually be altering properties of a viewmodel with such code which have no thread affinity.
If you're then going to directly access properties of ui elements then you need to use Dispatcher.BeginInvoke to get back to the UI thread.
I do that with an anonymous action in that bit of code but you can call a method or whatever instead if your logic is more complicated or you need it to be re-usable.
http://social.technet.microsoft.com/wiki/contents/articles/26070.aspx
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles -
Starting new threads from within shutdown hooks
I'd like to discuss this statement from the java 6 API:
"A shutdown hook is simply an initialized but unstarted thread. When the virtual machine begins its shutdown sequence it will start all registered shutdown hooks in some unspecified order and let them run concurrently. *When all the hooks have finished it will then run all uninvoked finalizers if finalization-on-exit has been enabled. Finally, the virtual machine will halt*. Note that daemon threads will continue to run during the shutdown sequence, as will non-daemon threads if shutdown was initiated by invoking the exit method. "
Now, my question is this: If I have a hook that starts a new non-daemon thread and then goes on to complete it's run() method, will the JVM finalize and halt? Or will it wait for my new thread to complete as well?
I trust the specification, and believe that the JVM will either not allow me to create the thread or will finalize and shutdown even if it is running. However it's not explicitly stated anywhere, and I think that it's a hole in the documentation.
I'm going to write a test case for this now. But chime in if you have thoughts.This is what happens if you start a new thread from a shutdown hook and do not wait for it to finish:
public class ShutdownTest {
private static class Shutdownhook extends Thread{
public void run() {
System.out.println("Shutdownhook starting");
Thread t = new Thread(){
public void run(){
System.out.println("Thread successfully started");
try{ Thread.sleep(5000); }
catch(Throwable e){ System.out.println("Throwable from sleep: "+e); }
System.out.println("Thread successfully finished");
t.start();
//try {t.join();} catch (InterruptedException e) {}
System.out.println("Shutdownhook completing");
public static void main(String[] args) {
Runtime.getRuntime().addShutdownHook(new Shutdownhook());
System.out.println("Exiting from main()");
Runtime.getRuntime().exit(0);
Exiting from main()
Shutdownhook starting
Shutdownhook completing
Thread successfully startedHowever, as you might expect, if you join() or wait for the thread's isAlive() to return false, you will be able to complete the thread.
I'll leave someone else to figure out if that new thread gets finalized and if finalizers on exit is on, what happens. Mostly because it doesn't matter for my purposes.
Enjoy -
Starting new threads from a servlet
Hi
I read somewhere that starting new threads from a servlet is not supported in the future releases of J2EE .
Any one aware of this.
I have a listener program started as a new thread from the init method of a servlet which is set to load on startup.
I have to think about another way to do this if this is not suppported in the future releases
any commentsDr clap
Actually I was getting some warning messages in my websphere server console when I tried to make JDBC connections from the thread I opened in the servlet.
Everthing works fine but with the warning messages,
Then someone from IBM answered me in one of the forums quote
Cause: These messages are being produced due to an
"unsupported" environment. When application is
spinning its own threads from an EJB, spinning a
thread and accessing a database is not supported (per
the J2EE specification). One exception to this rule is
if a Servlet is spinning its own threads and accessing
a database. The J2EE specification is not clear on
this, so WebSphere Application Server 5.0 must allow
for it at this time. IBM is working with Sun to
clarify this in the specification, so eventually (i.e.
J2EE 1.4) spun threads from a Servlet accessing a
database outside of a transaction will not be
supported either.
Since we don't want to promote the usage of these
"naked" threads accessing databases, we are producing
the warning messages. Although they may be filling up
the logs, we feel that these are necessary to warn the
user that they are doing something not in-line with
the intended usage. Customer should consider changing
their application to comply with the
J2EE specification.
""" -
How to call a RFC of a remote system from an ABAP webdynpro component
Dear Experts,
I am a newbie in ABAP Webdynpro.
I am working on a requirement where I have a webdynpro component on ECC system.I need to call a RFC located on CRM system from my webdynpro component on the ECC system.
How do I do that ?? Please help.
Regards,
Mamai.Calling RFC from some other system is same as local except the difference is that you have to give destination name while calling.
And the regarding the method of calling it depends on your FM.
if it is big RFC with complex structure, you can create the service call for it with destination given as RFC desitination.
if it is simple straight forward RFC you can directly call it.
for creating RFC service call call use this method
1. Starting the Wizard
To start the wizard, position the cursor on the Web Dynpro component to be edited in the object list at the left margin of the
workbench window. Open its context menu and choose the entry Create->Service Call. The wizard is started and leads you
through the creation process.
Press Continue.
2. Choice of Controller
On the second dialog window of the wizard, you can choose whether the service call is to be embedded in an existing
controller or whether a new controller is to be created for this purpose. Service calls can only always be embedded in
global controllers u2013 that is, in the component controller or in additionally created custom controllers. It is not possible, to
embed service calls in view controllers.
a. Select radio button Use Existent Controller
b. Do not change the default entry for component: <CC name>
c. Enter for controller COMPONENTCONTROLLER
d. Press Continue.
3. Service Type and Service Selection
a. You now select, which service type should be used for this service call. Select radio button Function Module. Fill the
destination here. Press Continue.
b. Select the service: for Function Module enter <RFC name>. Press Continue.
4. The Required Methods and Context Elements
On the two subsequent dialog windows, default values are listed for giving names to the context nodes and attributes
required by the service call as well as to the required methods. The proposed names are based on the names of the
embedded service, but you can change them as required. However, heed the respective notes in the corresponding dialog
box.
a. Adapt Context: Select from Nodes/Attributes . Press Continue.
b. Specify Method Name: leave all entries as provided: Component: Controller: COMPONENTCONTROLLER Method: EXCUTE_ Press Continue.
5. Completing the Choice
When you have confirmed the last dialog box, the generation is triggered. Afterwards you now have the required methods
and contexts at your disposal for using them within your Web Dynpro component.
or if you want to call directly the use the call statement with destination -
hai,
Im uploading a .css file and some images in Apex shared components ,now how to call the css file and images from my Application.... plz tell me detailed.....
Edited by: anoo on Nov 3, 2008 12:51 AMHi Anoo,
Sorry, didn't see that you'd started a new thread, so have answered this in 'undefined' is null (or) not an object "
Andy
Maybe you are looking for
-
How to change crystal report data field at runtime ?
Hello everyone, I have a Crystal Report file ,which i am using to generate report for my windows form project . In that report i have a filed called as Quantity which data type is set as decimal, the requirement is like that the number of value those
-
The error message suggests that I run 'chkdsk' utility, but something prevents this from runnning. I tried re-installing Firefox, but did not uninstall first. Is this the best approach ? AND .. Most important .. If uninstall, and re-install, Will I l
-
Updating ipod on windows xp-receiving Error (-69)
Hi, has anyone had this problem where I am tryng to update my ipod on my windows XP and it's telling me it cannot because of an error (-69) from the disc. Can anyone shed some light?
-
Encoding problem please help..
I am using XML parser V2.0.7 for C++. I have a stylesheet wherein <xsl:template match="some japanaese char"> When I run XSLSample , the XSLT processor thorws an error complaining LPX-314. Please reply
-
Hiding menu bar and toolbar in WinGUI used in transaction iView
dear friends can anybody help me to hide the Menubar and Toolbar displayed in WinGUI used Transaction iView please help me thanx in Advance kantha