I need a code that allows me to show a "Please Wait" Dialog while performing a lengthy operation

Hi,
I have very basic knowledge of C++ and I don't understand completely how this works. I have been trying to use pthreads in order to be able to show a "Please Wait" Dialog while performing a lengthy operation. The problem is that the dialog
box is showing up with a blank box where the label should go. Could you please modify the following code so that the program does what I am looking for? (note that I have pasted the sections of the program I think are useful for someone to provide an answer).
void *run_optimization( void *ptr );
void *run_optimization( void *ptr )
Solution x = Optimizer(); // Lengthy operation
const int * const SolArray = x.getDiscreteSolution();
return 0;
namespace RCM {
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Processing^ Proc = gcnew Processing();
Proc->Show(); // this is the "Please Wait" Dialog
pthread_t thread1;
int ret1;
ret1 = pthread_create( &thread1, NULL, run_optimization, NULL);
pthread_join( thread1, NULL);
Thank you!!
EDIT:
I have tried the following:
void *run_optimization( void ^ptr );
void *run_optimization( void ^ptr )
Processing^ Proc = (Processing ^)ptr;
Solution x = Optimizer(); // Lengthy operation
const int * const SolArray = x.getDiscreteSolution();
Proc->Close();
return 0;
namespace RCM {
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Processing^ Proc = gcnew Processing();
pthread_t thread1;
int ret1;
ret1 = pthread_create( &thread1, NULL, run_optimization, (void *)Proc);
Proc->Show(); // this is the "Please Wait" Dialog
But I am getting the following error:
error C2440: 'type cast' : cannot convert from 'RCM::Processing ^' to 'void *'

Hi Shu!
It runs in windows. I am using Visual Studio 2010 (and I can't use another version) which still doesn't have the threads integrated as I have read. So I am using POSIX threads for windows. 
Regarding the other question, I don't really know what either of those (.net framework library or native API) mean. I am sorry but I am really new at this and really don't know much but I am doing my best because I have to get this done.
I only know basic C++ but had to use C++/CLI windows forms because of a code I integrated in my program for running macros in excel and it was in C++/CLI.
Thank you for your help!
You cannot pass a managed handle to void* (as you have discovered).
If you really want to use Posix threads, you probably need to make your Processing class a normal C++ class, not a C++/CLI ref class.
But the .NET way to do this would be to use a BackgroundWorker:
https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker%28v=vs.110%29.aspx
David Wilkinson | Visual C++ MVP

Similar Messages

  • Is there a t-code that allows you to view the AUC Settlement Log?

    One of my counterparts in a different region would like to review the AUC Settlements for the prvious month.  Is there a t-code that allows one to view the AUC Settlement Log or is there a special procedure required to view those results?
    thanks in advance for your help.
    Dan

    This was perfect.  By the way the t-code for program RAHERK01 is:  S_ALR_87012058
    Thanks to everyone that replied.  The other two reports will help with some other needs.
    Dan
    Edited by: Daniel Goodhart1 on Nov 10, 2011 5:14 PM

  • I need an app that allows - top notch Powerpoint accessibility.  Notetaking and audio recording.  AND a possible translator.  Is there any appl or two that are recommended for a busy traveling executive?

    My boss just purchased and IPad and needs an app that allows -
    Powerpoint Editing and graphics capability/accessibility. 
    Notetaking and audio recording. 
    Japanese Translator.
    Is there any appl or two that are recommended for this busy traveling executive?
    Mahalo Nui Loa!

    dmkimball wrote:
    Japanese Translator.
    Have a look at
    http://itunes.apple.com/us/app/google-translate/id414706506?mt=8

  • I need an app that allows me to create a editable leaderboard by inputting a time and a name?

    I need an app that allows me to create a editable leaderboard by inputting a time and a name for up to 20 people and being able to edit and delete all the names and times when im finished any ideas?

    why not actually use a spreadsheet program?  You can do everything you describe in Excel. i don't use apples equivalent, Numbers, but Im sure it is quite capable.

  • HT1557 where do i find Universal Binary Component compatible with Intel-based Macintosh that allows quicktime to show video?

    where do i find the link to the Universal Binary Component compatible with Intel-based Macintosh that allows quicktime to show video?

    I think your question is too vague to get an answer.
    You're asking for a 'Universal Binary component' for your 'Intel-based Macintosh'. Why universal binary?
    universal binaries are designed to work on both PowerPC and Intel machines. If you're using an Intel machine why do you need PowerPC support?
    Also, you want something that 'allows QuickTime to show video'. Well, not to be glib, but QuickTIme does video - that's it's raison d'etre. Therefore I think your question is more about how to get QuickTime to show a specific (non-standard?) video format. Without knowing what that format is, it's impossible to answer your question directly.
    That said, maybe the place to start is Apple's QuickTime Components index.

  • T-Codes that allow changes to bank details

    Hi
    I need to have a list of all transaction codes that can be used to create or amend vendor details, especially payee name and bank details. I know of FK01, FK02, FB02 and F-43 (If INDIV PAYE option is available). Also, are there other optional functions (like INDIV PAYE) that could be available in screens that I need to be aware of?
    Thank you for any help
    Paul

    An update after playing some more.
    I filled in the details for the errant accounts but no joy. Also every time the pane loaded it was one account (the junk account) that kept getting it's data wiped. It also started to appear multiple times (once for every loading of the pane). I had to delete the account from my Apple's Mail program to get this to stop. Once I deleted that account in Mail the function worked. It failed to send my email because of the server setups but once I corrected that it seems ok. Strange function - seems unfinished. I shouldn't have to delete accounts in Mail to get this to work - ignore in iPhoto is cool if it worked.
    Sean

  • I need a spreadsheet that  allow any advanced functionality such as macros and active x components. Any possibility of that ever happenning?

    I have spreadsheets that contain macros. Unless and until software producers change the programming or capability that allow any advanced functionality such as macros and active x components, I cannot use my ipad. So I am forced to lug my laptop and my ipad around when the ipad would be perfect for my work in insurance. The fact that this capability does not exsist in docs to go or numbers means there either is a major hang up or these software manufacturers don't feel the need is strong enough. Either way, it really puts people like me in a bind. Does anyone have a solution for this? Is it really that hard of a thing to do to be able to read and run macros?

    Unfortunately there is NONE. I have tried searching for a long time but never succeeded to find an app that can read Macros. I hope there must be a very strong limitation for developers to support macros.

  • Sample code that allows System.inheritedChannel() to work?

    Hi,
    I would like to create a C program, which will launch a Java runtime. I want the C program to open a listening socket, then pass that listening socket to the started Java VM.
    I should be able to do this, and have the java VM inherit the listening socket, and then in the Java program, I should be able to get the listening socket with System.inheritedChannel().
    In theory, anyway, all the docs seem to state that this is possible. But the problem is that I haven't found any code that does this. I'm not sure how I should setup the listening socket so that its the one that is picked by the inheritedChannel() call. What happens if my C program has multiple sockets, both connected and listening? How is the correct one determined? And do I have to have any special implementation of SelectorProvider?
    Finding a working sample would really help me figure this out. Or, just any program that already uses this mechanism somewhere.
    Can someone point me to such a sample?
    Thanks,
    Greg

    The following 'c' code will first create a LISTEN socket then pass it to the Java application following. This, with the previous post show both passing connected clients as-well-as service sockets to java via System.inheritedChannel().
    #include "stdnet.h" // platform specific network headers
    int
    main(int argc,char *argv[])
         pid_t     childPid = (pid_t)-1;
         // setServiceOnHostPort() creates bound LISTEN socket
         int          service     = setServiceOnHostPort("127.0.0.1",13333);
         fprintf(stderr,"service socket is %d, on port %d\n",
              service,getServicePort(service));
         // create child process in which to start the jvm
         if               ((pid_t)0 > (childPid = fork()))
              fprintf(stderr,"Cannot fork(), errno = %d\n",errno);
              exit(-1);
         } else if     ((pid_t)0 != childPid) {
              // close replace the tty fd with our service (LISTEN) socket
              dup2(service,STDIN_FILENO);
              // close the others, just in case
              dup2(-1,STDOUT_FILENO);
              dup2(-1,STDERR_FILENO);
              // stdin == service so we can close service now
              close(service);
              execvp(argv[1],&argv[1]);
              /* Failed to start application, pause before exiting w/ 123 */
              _exit(123);
         } /* if          ((pid_t)0 > (childPid = fork())) */
         // parent can leave now, of course its better to see if jvm actially
         // started here by looking for child's exit code of 123.
         return(0);
    } /* int main(int argc,char argv[]) /
    Now the java code.
    import java.io.File;
    import java.io.PrintStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.nio.channels.ServerSocketChannel;
    import java.nio.channels.SocketChannel;
    public class jInetdApp
         public static void main(String[] args)
              throws Exception
              System.setOut(new PrintStream(new File(
                   System.getProperty("user.dir") + "/java-inetd.out")));
              System.setErr(new PrintStream(new File(
                   System.getProperty("user.dir") + "/java-inetd.err")));
              Object stdInObject = (Object)System.inheritedChannel();
              // started w/ connected socket
              if (stdInObject instanceof SocketChannel)
                   SocketChannel channel =
                        (SocketChannel) stdInObject;
                   Socket socket = channel.socket();
                   System.err.println("channel: " + channel);
                   System.err.println("socket: " + socket);
                   PrintStream ps =
                        new PrintStream(socket.getOutputStream());
                   ps.println("Hello world");
                   ps.flush();
                   ps.close();
                   socket.shutdownInput();
                   socket.shutdownOutput();
                   socket.close();
              // started with service (LISTEN) socket
              } else if (stdInObject instanceof ServerSocketChannel) {
                   ServerSocketChannel channel =
                        (ServerSocketChannel) stdInObject;
                   ServerSocket socket =
                        (ServerSocket)channel.socket();
                   System.err.println("channel: " + channel);
                   System.err.println("socket: " + socket);
                   Thread.sleep(30000);
                   socket.close();
              // started from command line??
              } else {
                   System.err.println("stdInObject: " + stdInObject);
              } if (stdInObject instanceof SocketChannel)
              System.err.flush();
              System.out.flush();
         } // public static void main(String[] args)
    } // public class jInetdApp
    I hope this is helps.
    cj

  • How to develop a Java code that allows other applications to interact

    I would like to program a Java code, in order to allow to third party
    applications (e.g. VB or Power Builder applications ) to call specific
    functions (exposed by me). Is this possible in Java?
    As i m totally new to Java ... i need to know where to start with
    Should i go with
    - Applet or
    - Servlet or
    - Beans
    Thanks :)

    Thanks for the advice dude .. i appreciate what you just said ... i will go thru it definitely ...
    i m not very new to Java ... i m confortable with Core Java ... Just i wanted to understand whether i shud go with JavaBeans ?
    and if so,
    as i understand it correctly ... the jar file will be placed on the third party tool application server(developed in ASP) and the application will call the function (of my jar file)along with parameters to that jar file thru an interface ... and my jar file will calculate the logic and return the string to the applications ASP Page.

  • I need a code that connects 3 computers

    hi
    I am new to java
    I need a java program to that connects three computers. The program should give the
    users the ability to:
    ? send messages to another computer
    ? send messages to two other computers
    ? receive messages from all or any one computer
    ? typing messages should not block receiving messages
    can anybody please post the code
    thank you

    pavani wrote:
    hihi
    I am new to javaCongrats
    I need a java program to that connects three computers. The program should give the
    users the ability to:
    • send messages to another computer
    • send messages to two other computers
    • receive messages from all or any one computer
    • typing messages should not block receiving messages
    can anybody please post the codeNo. This isn't a fuckin code mill. If you want the code either buy it or create it yourself. If you do create it yourself, we can help you if you hit stumbling blocks, but it still has to be your work and your code.
    thank youYou're welcome.

  • I have IOS Version 10.6.8 and want to download pages, but it will only allow 10.9 ios only, is there anyway to get the older verson of pages downloaded? I hope someone can help me, as I am needed a program that allows Greek and Hebrew languages for docs.

    I was told by a friend that pages would help me do greek and hebrew documents if needed. I went to download, but the requirement is 10.9 IOS. Thats only on the new macbooks. Can anyone recomment another product to do these docs, or do I just have to wait on the 10.9 IOS to be released?

    Thanks...here it was mine says...
    Hardware Overview:
      Model Name:          MacBook
      Model Identifier:          MacBook7,1
      Processor Name:          Intel Core 2 Duo
      Processor Speed:          2.4 GHz
      Number Of Processors:          1
      Total Number Of Cores:          2
      L2 Cache:          3 MB
      Memory:          2 GB
      Bus Speed:          1.07 GHz
      Boot ROM Version:          MB71.0039.B09
      SMC Version (system):          1.60f6
      Serial Number (system):          W80337U2F5W
      Hardware UUID:          BEB7FA07-9857-5F9D-B2FD-764A1DA74BFA
      Sudden Motion Sensor:
      State:          Enabled

  • Need an app that allows 1 touch # dialing from notepad.

    I never carry pen & paper yet frequently need to write down a phone number temporarily. I normally use notepad but the problem is that I have to memorize the number because I can't just tap on it to dial. Is there a program out that can do this? Preferably FREE but any suggestions are very welcome. Thanks!

    cut and paste in the native format is built into the phone's OS.
    although, there is an alternative. a dude is writing an open source alternative. the problem is that since due to the restrictions on apple's SDK (for one thing, 3rd party apps cant really reach out to the lower level of the OS), that his app needs to built into other 3rd party apps in order for the C&P to work.
    so current 3rd party apps needs to be re-written to utilize his app...
    kinda cool, yet kinda sad that apple forgot such a low level functionality...

  • I need a utility that allows OC from within windows

    Hi,
    I have a P6N SLI V2 mobo, E4400, 7600gt, 1gb ddrII 800Mhz running XP pro sp2.
    The MSI utility "dual core center" is absolutely useless as it won't let me access any MB parameters (maybe MSI should test their f***ing software before they ship it), anyway I was wondering if any of you know of a good utility which will allow me to OC from within windows.  Thanks.

    I'm what you may call a retired OC'er, I used to clock the hell out my systems, back in the day when I had an athlon xp 1800+ cpu.
    Now, I don't game as much (or sadly, at all) any more, and the system is powerful enough to keep me happy most of the time. 
    But sometimes I do want to squeeze some extra juice out of my system, for these times I want a little more, I don't want to be bothered with going into the bios and start stability testings every time I up the FSB by 5Mhz.  I just want a simple interface that lets me do just that.
    Gigabyte has a fantastic utility ("EasyTune") just for that, which made OC'ing life as easy as it gets.  I'm sort of disappointed with MSI for shipping that cr@p of a software they call by the fancy name "Dual Core Center" (my my, such big name for such a little (worthless) program).
    Anyway, just to clarify it again, I can OC myself via bios (well, I think I can...), but I'm too f***ing lazy for that.   
    Help the lazy man get a program which will do all the dirty OC work for him...
    BTW, thanks for all your help people! 

  • MacBook neophyte.  Need an app that allows me to open an excel spreadsheet.  Thoughts.

    Can someone tell me of an app that will allow me to work with an excel spreadsheet.  Thanks.

    No. You can donwload for free from http://www.openoffice.org
    Allan

  • I need a form that allows the creation of multiple records

    I have a form that is a daily timesheet. It's essentially a table with repeating rows, each row showing a record of time worked. Is this possible to produce in Form Central? I can't find any options relating to adding records.

    You can consider uploading files in B/CLOB columns, just the way u upload and retrive the images.

Maybe you are looking for