×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    280

    How to apply multithreading in s40 app.

    I m working on s40 app. I have a splash screen that should appear for 3 seconds when my app runs. After that i wanna run my parsing code which will ask user to click yes for internet connection.

    After that as soon as parsing starts i want to show progress bar(progress bar is done through animation with 10 pics). And when parsing is done i want that the progress bar should close and new form should appear .
    How to apply multithreading in these.. I used the following code. but it is not working fine Plz help

    protected void startApp() throws MIDletStateChangeException {
    Display.init(this);

    busy=new Form();
    Thread t=new Thread()
    {

    public void run(){

    try{

    image = Image.createImage("/splash.png"); //....................thread for splash screen
    busy.getUnselectedStyle().setBgImage(image);
    busy.show();

    } catch(Exception e)
    {
    System.out.println("error in image"+e);
    }

    }
    };
    t.start();

    Thread t2=new Thread(){
    public void run(){

    // thread for progress bar and and parsing date both defined in different classes
    try {
    //sleep(5000);
    progressbar p=new progressbar();
    p.loading();
    javaclass ob=new javaclass();

    v=ob.mainparsing();


    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }};
    t2.start();


    Form f3=new Form(); // this is the form i want to show immediately after parsing
    Label lg=new Label();
    lg.setText("PARSING DONE");
    f3.addComponent(lg);
    f3.show();

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: How to apply multithreading in s40 app.

    Actually i dont understand your question, do you want to know which things you can start in a separate thread ??

    from the current piece of code and details i think there are two places which you can start in a new thread.

    1. Your Http Connection which gives you response for your parsing code.
    2. Your progess bar other wise this will block your UI.

    And to do that it is rather simple and call

    Code:
    new Thread {
     public void run() {
        'code in another thread'
     }
    }
    Please elaborate if you want something else !!

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to apply multithreading in s40 app.

    Actually i want to know how to show something in thread for 3-4 seconds. I want the thread to execute for 3-4 seconds. And then i want the next should execute . When i am running my code as below whats happening is my code is not running from top to bottom. It is showing me f3 form then progress bar then splash screen. I want them in order from top to bottom. How to do this

    i want to show in following order . I know how to make threads :
    1. splash screen(for 3 seconds)
    2. progress bar till parsing is running
    3. form to show results of parsing

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: How to apply multithreading in s40 app.

    While the topic is a bit different, these two pages discuss a little about how you can move certain activities to secondary threads: http://developer.nokia.com/Resources...-commands.html, http://developer.nokia.com/Resources...tive-apis.html.
    If you want to make your code future-proof (like it should work on the Nokia Asha 501), you will need these documentations anyway.

  5. #5
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to apply multithreading in s40 app.

    Wizard. Also i am facing some problems as rms is taking much much long time to parse(due to large records). And even search and even fetch and in future since my app will we taking more of data. I have no clue how to find solution of problem. Also since i dont have much access at the server side, i am just given a link to parse my data. I am not getting any reasonable ideas how can i increase the speed of adding,fetching,searching,parsing in my app since we cnt let user wait too long. That will be a disadvantage.

    Is there any solution in rms only cz i am very very familiar with it now and finding it easy to use.

    best Regards

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: How to apply multithreading in s40 app.

    Quote Originally Posted by Manpreet_Singh View Post
    i want to show in following order . I know how to make threads :
    1. splash screen(for 3 seconds)
    2. progress bar till parsing is running
    3. form to show results of parsing
    Hello Manpreet_Singh,

    from your question it seems you want to handle events asynchronously and then take action based on the completion of the event. I think you need use some interface classes and that design pattern.

    Now for your splashscreen, you can start a view , create a sleep for the time you want your splashscreen to be visible and then start your next event. check this for more details https://projects.developer.nokia.com...gASplashScreen.

    Next is your HttpRequest and Parsing routine, you can make them in a separate class, initialize the http class in your view, along with this you can make a interface class and let your view implement that interface. In your http class get the interface object from your view and whenever you want to notify your view about anything happening you can do that with the use of that interface object.

    Same applies to your parsing routine too. learn about interfaces http://docs.oracle.com/javase/tutori...interface.html

Similar Threads

  1. RFs and Multithreading
    By dennis_george in forum Symbian
    Replies: 5
    Last Post: 2009-11-12, 17:09
  2. connector in multithreading?
    By SYTDeath in forum Mobile Java General
    Replies: 3
    Last Post: 2008-09-11, 08:36
  3. MultiThreading
    By anantwakode in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-02-28, 16:29
  4. C++ Multithreading
    By amit1878 in forum Symbian
    Replies: 3
    Last Post: 2003-05-22, 14:58
  5. multithreading
    By sridhar_ratna in forum Symbian
    Replies: 0
    Last Post: 2003-04-10, 04:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×