Results 1 to 6 of 6

Thread: Big threading problem

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Big threading problem

    Hi All,

    Heres my problem.

    I have a standard windows application called winap.
    I have a com component which acts as an api to the winap.
    I have a class in winap call classapi which has all the methods that the api calls and all works well.
    The problem is that one of the methods in my class api needs to get a handle on form elements in the main worker thread. Whenever I try to access an existing form I keep getting null because the for exists in the main worker thread and my api call is in a seperate thread.

    Any ideas how I can overcome this?
    Is it possible ?

    Thanks In advance

    Parksie

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Big threading problem

    Forms don't exist in any thread. They just exist. Threads are not about data; they are about instructions. Instructions are executed on a specific thread but all those instructions have access to exactly the same data.

    You're going to have to explain more clearly your situation because I can't tell whether you're saying that your app is making calls to this COM API or your app is providing this API to COM components.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Big threading problem

    OK. I'll try and be a little clearer tyhough to be honest I have been looking at this for so long I am confusing myself.

    I have a testbed VB 6.0 application which references my COM component which is a COM callable .net assembly.
    One of the COM methods is "Show Form 1()".

    My COM callable assembly is part of my .net windows soultion. When building my solution it auto registers the COM bit.

    When the VB 6.0 application calls "Show Form 1()" the COM object itself calls a method in my Winap which is supposed to do the work of showing the actual form. This code fires without any problems. I placed a messagebox in this method and it opens fine but it opens in a different thread as it is not modal as far as the winap is concerned.

    I cannot for the life of me reference any existing properties in the main application as they are in a different thread.

    For example when my winap first loads it sets a bunch of static properties so I can access them anywhere. winapp.Global.Variables.UserSettings["CuirrentUser"] in my winapp will always return "VenerableBede" but when I try this via the COM call it is always NULL.

    Man I am even more confused.
    If you get this you are a genius.

    Jeez jmcilhinney. I have jsut noticed...over 50,000 posts. WOW. Do you live here ?

    Parksie

  4. #4

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Big threading problem

    Because I am dealing with 2 different app domains I think I may have to go down the COM+ route which I would prefer to avoid but I can't think of any other way.

    This is a nasty one.

    Parksie

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: Big threading problem

    Isn't the problem that you are actually dealing with two different instances of data? You aren't sharing the same form in your vb6 app and your .net one.

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Big threading problem

    Quote Originally Posted by Edneeis View Post
    Isn't the problem that you are actually dealing with two different instances of data? You aren't sharing the same form in your vb6 app and your .net one.
    My thoughts exactly, I dont think this has anything to do with threading. I've never done any COM stuff at all though so I dont think I can help I'm afraid..
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

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



Click Here to Expand Forum to Full Width