This is very important... It concerns topics of threads and sockets...

Hey...
This has been very complicating for me.
I have tried so many solutions for the past
few days but i have been stuck here with no
no things to think of. I would really appreciate if someone
can help me out in doing this or any suggestions.
Now this is the case..
My program runs a frame with an "OPEN" menuitem
a connect button ,upload button, a porgress bar and a progress text label near it.... In the open u choose a file that u want to upload. In the connect u choose the IP address that u need to Upload the chosen file to. And in the upload, u start uploading u're file. Now i am using sockets to connect through my machine and the chosen IP address. The progress bar should note the process of uploading and accordingly get's updated...The progress text label should either say "No String" or "Uploading" when i'm uploading as well as blinking on and off....
Now i got through almost all of the stuff above, i'm only stuck in updating the progress bar and the text. To make things more clearer i will include the upgrade method that i do the connection and start sending the stuff. In there i've also created a thread to update the bar but for now, i only set the value to 10.... The thing is it never updates the bar unless the whole process of downloading is done. The file chosen to be uploaded is about 1MG and it takes about 40secs to send the whole file to another machine.....
I've also tried using seperate threads in different classes
but it never worked..
NOW THE PROGRESS BAR HAS BEEN DECLARED IN THE
PROGRAM AS JProgressBar. What i'm suppose to do is
read the file in 29 bytes. Then send 15 and then 14.
Once i'm less than 29 bytes i send either 15 or 14 or
the remainder... The sendMsg method is the one that
handles sending the bytes and receiving the
acknowledgment. The socket is created when i hit the
connect button and choose the IP address...
Please any extra suggestion is appreciated.
/CODE/
public void UpgradeActionPerformed(ActionEvent e)
final Runnable doprogressValue = new Runnable()
public void run()
jProgressBar.setValue(10);
Thread appThread = new Thread()
public void run()
try
SwingUtilities.invokeAndWait(doprogressValue);
catch (Exception ex)
ex.printStackTrace();
try
DataInputStream inputStream = new DataInputStream(new FileInputStream(fileName));
//Send Set to DownLoad Moad message
byte[] msg = new byte[MaxMessageSize];
msg[0]=(byte)((SystemSpecific<<4) | (DataCounter));
msg[1]=FirmWareDNLMode;
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
//Set Progress Bar Max & Min values
jProgressBar.setMinimum(0);
jProgressBar.setMaximum(inputStream.available());
while((inputStream.available()) >= MaxMessageRead)
bytesRead = inputStream.read(mainBuffer,offset,MaxMessageRead);
//Send First 15 Bytes
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
//Send Next 14 Bytes
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
//Send The 15 Bytes Left
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
//Send The 14 Bytes Left
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
//Send The Remainder Bytes
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
//Send Set to Reset Mode
returnVal=sendMsg(msg, rcvMsg);
if(returnVal == false)
return;
inputStream.close();
socket.close();
connectionStatus.setText("Not Connected");
fileStatus.setText("Loading completed");
upgradeButton.setEnabled(false);
connectButton.setEnabled(false);
catch(NullPointerException null_ex)
JOptionPane.showMessageDialog(null,"Connection Not Created","Error",JOptionPane.ERROR_MESSAGE);
catch(IOException IO_ex)
IO_ex.printStackTrace();
appThread.start();
/CODE/

Yeah... i dide finally figure out a way doing it.... This is how i did it....
/CODE/
// This is all going to be under the upload action...
{//beggining of the uplaod action
finally Runnable doProgressVal = new Runnable()
public void run()
time.start();//This is an instance of class timer that i
// created. It actually sets the value of
// of the progressBar to the latest upload
Thread mainThread = new Thread()
public void run()
SwingUtilities.invokeAndWait(doprogressVal);
do the uploading of the file to the specified server
mainThread.start
}//end of upload action
/CODE/
Hope this help if u want it for something. It works fine..

Similar Messages

  • HT204053 Me and my daughter had been using the same apple id, she was triyng to change it now all of my iphone contact are gone, what can i do ti get it back , this is very important to me.

    Me and my daughter had been using the same apple id, she was triyng to change it, now all of my iphone contact are gone, what can i do ti get it back , this is very important to me.

    Your contacts are helpd on the server, so if you sign out from your iCloud account and sign into another one they will disappear. If you sign back into the original account they will reappear.

  • Im using intel macbook pro 13" and since I'm using the new OSX Lion, the keyboard backlit won't turn off and it's eating up my precious battery. Im always mobile so this is very important. Apple doing something to fix this bug immediately?

    Im using intel macbook pro 13" and since I'm using the new OSX Lion, the keyboard backlit won't turn off and it's eating up my precious battery. Im always mobile so this is very important. Apple doing something to fix this bug immediately?

    multiplryan wrote:
    To be totally honest, about 3 weeks prior I spilled some milk from cereal on the desk and a little bit got onto the battery.
    I don't think you have a case.
    You can replace the logic board yourself if you are a DIY'er and save some money.

  • I deleted a very important pages file from my iPad and I need it back

    I deleted a very important pages file from my iPad and I need it back pronto! I just updated my iPad without a computer and it had the file there. I need to know how to get back the file very quickly.
    thx in advance

    Thne unfortunately, your document is gone. You can restore lost or deleted documents from backups if you have backups - and as long as the backup contains the document - but if you did not copy the file to your computer - or backup the iPad, the document is gone.
    You really should start backup up your iPad. You can sign up for a free 5GB iCloud account right on the iPad and then you can use iCloud for backing up. You can do it right on the iPad.

  • SoundFonts - small problem. Please help me because this is very important to

    Hello everyone. I have just upgraded from a SoundBlaster Audigy, to a SoundBlaster X-Fi Music edition.
    I have a collection of soundfonts which I used to use on my Audigy. They worked fine. Now that I'm using the X-Fi, they all work well, apart from one, and the one that doesn't work is my most used, most important soundfont.
    Description of problem:
    When I run my midi file, it starts playing the music using the new soundfont, but after about 0 seconds or so, the sound stops - even though the music is still playing. I then can occasionally hear a note or two, but its no longer playing properly. All my other soundfonts work perfectly, so I really dont understand why this one would cause troubles. They are all .SF2 files.
    Other Information:
    ) I am using "SoundFont Bank Manager" to load the soundfonts. They all work great apart from the main one I want to use. It worked fine on my Audigy. The Cache part says 7.3mb Used/ 229.8mb Free.
    2) I am on Windows XP Professional - Service pack 2.
    3) The rest of my computer is very powerful. Its a core2duo, 2gig of RAM, 320gig seagate barracuda hard dri've etc. Regularly defragged.
    4) I have the latest soundcard drivers (And direct X, video drivers, bios drivers, etc.).
    5) I have no other problems with the computer.
    6) My Midi program is Guitar Pro, which plays special midi files. It is set up properly, and it plays everything perfectly - using all my soundfonts, except the one I most want to use..
    Please help me get this working. It is very important to me, and I need to get it working as soon as possible. I'll keep searching this thread incase I need to give any more information.
    Thanks in advance.Message Edited by acrobat on 02-09-200705:0 AM

    Why do you have two threads dealing with the exact same issue. That makes it confusing and hard to follow your issue to help you.
    Who is your carrier, I asked in the other thread?
    Have you tried YOUR sim card in another device, what happens?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • My scroll feature of the Lenovo ThinkPad(red scroll) is not working in the new Firefox 4. It was working fine in 3.6. Can you please fix this as this is very important feature.

    The scroll feature(middle button) is not working on the new firefox 4. So because of this I need to move the scroll bar to move the page. This is very irritating problem, if you are a guy who uses the middle button to scroll. Can you please fix this..
    Thanks!!!

    I updated to Firefox 4.01 today and the middle scroll button on my Lenovo T400 stopped working. I downloaded the updated Ultranav utility and the Ultranav driver for my T400 from here http://www-307.ibm.com/pc/support/site.wss/MIGR-72858.html and then uninstalled the "Thinkpad Ultranav Driver" from Add/Remove programs rebooted and then installed the updated utility and driver (another reboot) and it now works perfectly.
    So glad to get this working again.

  • I can no longer view source files in Firefox 6. This is very important for my job as an SEO consultant.

    Under View I can no longer read the Source files for a webpage. As an SEO consultant this is vital for my work. Please can you restore this feature for FireFox 6.

    You can also use these shortkeys:
    * Web Console -> CTRL + SHIFT + K
    * Scratchpad -> SHIFT + F4
    * View Page Source -> CTRL + U
    * Error Console -> CTRL + SHIFT + J
    Check and tell if its working.

  • I need to restore a video that I deleted from my iPhone. This is very important.

    I recently have been having problems with harassment at college and had a video as proof saved on my iPhone. It accidentally got deleted and now I don't have my proof. Is there any way to get it back if it wasn't saved to the iCloud?

    Video does not have dpi. Pixel size is fixed. dpi is a print function. The only way to create 300dpi is to use scaling in Photosop or to use a dedicated application like PhotoZoom Pro, which is what I have always used for my books to create high resolution print images of screen shots.

  • This is very important, not even joking.

    I updated my iTunes to the newest version just a day ago, and every single piece of music and video I had on iTunes disappeared. Everything is completely gone and I'm freaking out. Not only because EVERY FOLDER IS BLANK, but also because I really don't have the time or patience to re-upload 45 days worth of music. Can someone please tell me what happened, or where all of my music went?

    Welcome to AD!
    Sounds like you have 2 problems going on.
    For the itunes library being empty, try these directions
    http://support.apple.com/kb/TS1967
    Just skip step 2, since you just updated itunes.
    For itunes asking you to configure everything all the time, that is usually a problem with the itunes shortcut. Go to C:Program Files/iTunes and right-click on itunes.exe. Make a new shortcut for itunes and use that to start itunes - does it work OK, now?

  • !!VERY IMPORTANT - STOLEN PHONE - EVIDENCE REDCOVERY!!!!

    As hard as this scenario is going to be hard for most to believe, I attest that the facts you are about to read are completely true!
    On 03-10-09 I was unjustly brutalized by police officials in my city.  I had the Blackberry Voice Recorder running, recording the entire incident to my phone's memory.  Aware of the recording, the officers involved picked my BB up and refused to return it and denied having it.  This recording on my BB is my LIFELINE to justice.  I was wondering if ANYONE, including a BB PROFESSIONAL knows of ANY routes i can take to recover this phone or the recording on it.  This is very important to bring justice to this traumatic  experience I was forced into two days ago. PLEASE HELP!!
    Thank you in advance,
    Kimberly
    PS: My NETWORK is ALLTEL btw, who told me there was "nothing" they could do as far as GPS tracking or data recovery to find that recording. THIS IS SERIOUS!! PLEASE NO LESS THAN SERIOUS RESPONSES!! THANK U!

    That's incredible! Thirty-nine reads and not ONE suggestion?
    This is the problem right there... everyone takes stuff like this as a joke.
    Like I have time to waste.
    Thanks anyways, I will leave the help to the professionals a.k.a. my lawyer.
    I just hope it never happens to one of you.

  • How TO CALL c++ EXECUTABLE FROM XI(VERY iMPORTANT)

    hI ALL
    pLEASE DO GIVE SUGGESTIONS AND DOCCUMENTATION LINKS  THAT <b>HOW TO CALL c++ EXECUTABLE FROM XI</b> .THIS IS VERY IMPORTANT AND YOUR HELP WILL BE REWARDED.
    WITH REGARDS
    SUBRATO KUNDU

    Hi Subrato,
    AFAIK you can call C / C++ methods in Java using Java Native  Interface (JNI).
    Please refer the following links for how to do the same.
    <a href="http://www.nag.com/IndustryArticles/CallingCLibraryRoutinesfromJava.pdf">For C:</a>
    <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip17.html">For C++:</a>
    Regards,
    Ananth

  • I have numbers on my ipad and after the latest update I can't open a spreadsheet in it, a very important spreadsheet. I have rebooted a number of times but this does not seem to have fixed it can someone advise what I can do??

    I have an ipad and have just downloaded the lastest update, now I have a very very important spreadsheet that will not open!!!! other spreadsheets open fine but for some just this one will not open. I have rebooted the ipad and tried re-syncing but to no avail, can anyone HELP?????

    I had the same problem. I created an iCloud account and backed up my iPad to iCloud. I then went to www.iCloud.com, signed-in and then I was able to download my spread sheet data. At least I have my data.

  • So my ex step-daughter took my daughters ipad 4 and changed her passcode and is denying doing it but we know she did. she does things like this. my daughter has pictures on there that is very important to her. her late grandfather etc. how can we get into

    so my ex step-daughter took my daughters ipad 4 and changed the passcode. she is NEVER giving me the new passcode.  my daughters has pictures on there that are very important to her. pics of her late grandfather, etc. how can we get back into the ipad without losing her items??? shes heartbroken..

    Removing the "Disabled" will erase the iPad. If you have important files on an iPad you should backup frequently.
    How can I unlock my iPad if I forgot the passcode?
    http://www.everymac.com/systems/apple/ipad/ipad-troubleshooting-repair-faq/ipad- how-to-unlock-open-forgot-code-passcode-password-login.html
    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    You may have to do this several times.
    Saw this solution on another post about an iPad in a school environment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just canceling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • Apple has a problem and the cant solve it. I had some very important call but this new iphone just shut down on me and wont turn on i tried everything u can find in apple support nothing works for me. Anyone know what i can do?

    Apple has a problem and the cant solve it. I had some very important call but this new iphone just shut down on me and wont turn on i tried everything u can find in apple support nothing works for me. Anyone know what i can do?

    I would instead say you have a problem since nearly all IPs work as advertised.  IF you do have a bad phone, take it into an Apple store and get a replacement.  Hope you didn't jailbreak your phone though as Apple probably will tell you, you broke it, you fix it.

  • When i call someone who already connected with another call it doesn't show any wating notification. why? it is very important. all other mobiles have this potion. Please give me some solution.

    when i call someone who already connected with another call it doesn't show any wating notification. why? it is very important. all other mobiles have this option. Please give me some solution.

    Your iPhone can take multiple calls. If you answer your phone from one person or call someone and another call comes into you, you will hear a beep and if you pull your phone away from your ear, you will see that you can hang up the call with the 1st person or answer the 2nd call and then swap between the two.
    I have no idea what you mean by you calling someone who is already talking to someone. I've never been able to see on my iPhone that someone I'm calling is already talking to someone else.

Maybe you are looking for

  • Videos no longer recognised as videos in my ipod

    Hello, I've downloaded various videos and vodcasts from the itunes store. Never had any problem viewing them before. About a week ago, I plugged my ipod into a different laptop for charging and now the ipod no longer brings up lists of movies etc und

  • Trigger not firing

    Dear Oracle Guru's We have four transaction tables in which we have triggers. whenever any changes like Insert,update,delete happens . the triggers Insert, update,delete another consolidated transactions Table. We found that on certain occurence , th

  • Passing value to RFC

    Hi Friends I have a requirement where I have to pass few values from Adapter Module to RFC which will update the database table. Example: I have to pass filename and filesize to RFC which will update the table X Could someone provide me the snippet o

  • Accessing Simple Type Variable Defined in BPEL Flow, in Transformation

    Hi, I am using Transform Process Activity. In transform mapping, i would like to map one target element with a value defined in a 'simple type variable' which is defined in calling BPEL Flow, however I am not able to do it. for example: I have a BPEL

  • J'ai un message d'erreur lorsque je veux telecharger un livre  merci de m'aider le chat ne repond pas

    Bonjour impossible de telecharger un livre acheté j'ai un message d'erreur TELECHARGEMENT IMPOSSIBLE PROBLEME DE COMMUNICATION AVEC LE SERVEUR DE LICENCES E_AUTH_BAD_DEVICE_KEY Pouvez vous m'aider Merci