.NET Components for Mobility

Brecham Source Code

Last post 09-24-2008 3:55 PM by Andy Hume. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 09-22-2008 2:12 PM

    Brecham Source Code

    Is the Brecham Source Code available?

    I'm having problems trying to download a file when I do it from a different thread (not the UI thread).  The thread hangs and never complete the operation.   The code is simply: 

    "session.GetTo(fileStream, name, null);"

    This works perfectly if called in the UI thread.

    I would like to have the source code to compare session.GetTo and session.GetFolderListing, because the later doesn't hang even in the thread.

    Thanks a lot,

    G.

  • 09-23-2008 3:29 PM In reply to

    Re: Brecham Source Code

    I haven't released the source code so far.  It's something I've thought about but never decided on.

    That there's little in the library that is thread sensitive.  The operations are all carried out simply on the thread used by the client code, and the only 'interesting' inter-thread stuff occurs if the user calls Abort from a different thread (yikes!). 

    GetFolderListing is effectively just: 

        ObexGetStream strm = Get(null, ObexConstant.Type.FolderListing);
        Objects.ObexFolderListingParser parser = new Objects.ObexFolderListingParser(strm);
        Objects.ObexFolderListing listing = parser.GetAllItems();
        return listing;

    Note that it calls Get as opposed to GetTo.  So can you try and see what happens if you replace your GetTo with a Get, also adding code to read to the end of the stream to. Something like

        using (Stream src = sess.Get(name, null)) {
            while(true) {
                int readLen = src.Read(buf, 0, buf.Length);
                if (readLen ==0) break;
                // Include this to write to the stream as written to by GetTo,
                // but it's unnecessary for the initial testing.
                //   dst.Write(buf, 0, readLen);
           }//while

    I presume that the content you're reading in the GetTo is different from you're reading in the GetFolderListing, so maybe the server itself is hanging in delivering the content.  If your test code above still fails to complete then that's likely the case, we could turn on some sockets debugging to see when it hangs.  What's the server BTW?

    Most of the samples use Get from a background thread, but not GetTo similiarly.  I've just added a very simple test case to my unit-test and if passed fine and will try an example in a WinForms app if I get a moment.

    Andy 

  • 09-24-2008 5:16 AM In reply to

    Re: Brecham Source Code

    Using Get instead of GetTo it works perfectly even in the thread.   The server was a N95 phone.

    I don't know why it fails with GetTo, but I have no problems now.

    Thank you very much for your help,

    G.

     

     

     

  • 09-24-2008 3:55 PM In reply to

    Re: Brecham Source Code

    Hmm wierd!  It is possible you could supply more information, perhaps one or both of the following:  If the download hangs then it'd be good if it could be run in a debugger and the location (stacktrace) of the thread at the hang.  I'd be interested in seeing the network log to the server too.  See the config file in the release ("Samples/Enable Network Logging, rename to app.exe.config"), copy it next to your app's .exe, rename it to match and run your app to show the hang, a log file will be created, and you can email it to me.  Don't know whether this site's email system allows attachments, so I'm at yahoo.co.uk and am andyhume32.

    Andy 

Page 1 of 1 (4 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.