Re: Want form to show changing data. But it could be closed, or closing, during update.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You call Invoke() from a static method the same way you'd call from an
instance method, except of course you need to explicitly specify the
instance on which you want to call Invoke(). Obviously this means you
need a reference to the form somewhere......[snip]

Yup, and that's the issue, to have that reference, and to use it when
it could change on you at any moment.

Well, IMHO that's a design problem. I don't think you should design your
code so that that could happen. In particular, it sounds as though you
have threads that can continue to run after your form is closed. But
really, that's a bad idea if you expect those threads to want to
communicate with your form.

Instead, it would be much better to simply have the form not close until
the threads are done. That way, you can be sure that when you go to
Invoke a delegate on the form, the form will still be there.

Pete, the data is coming through a socket connection, and who knows
when the data will arrive. Since the form is just to show the current
stream of data, and is not the main form, I don't want the form to
exist for all time, and be processing all the time (it takes up memory
and CPU resources). I want it to allow it to be opened/closed as
desired. When open, it will show the current data (but also update in
real-time).

Right now, this socket thread checks to see if the form exists, and if
so, invokes a method on it to update itself. There's still that
little chance the form could disappear right AFTER the existance
check, but BEFORE the reference is used to invoke. Things are
properly synch'ed AFTER the invoke, but not before, so that's the
danger area. (I could catch exceptions to prevent a crash, I
suppose).

Zytan

.



Relevant Pages

  • Re: CALL using OMITTED
    ... look for ways that Cobol can help with this. ... invoke MyCollection "new" returning CollectionObject ... I've never done it so I don't know the full implications - hopefully it creates a unique reference in the first Collection without impacting the second. ... Procedure Div using.... ...
    (comp.lang.cobol)
  • Re: new block notation (was: Re: ruby-dev summary 26468-26661)
    ... It is possible to invoke all three in an arbitrary scope (where 'self' and instance variables refer to a specific, runtime-chosen instance of any class) by passing them as a block to a special ... It is possible to get a reference to a method and assign it to a variable. ... It is possible to invoke a method reference in the scope of the instance to which it is tied without supplying the instance as a receiver. ... Lambdas are not associated with any specific instance. ...
    (comp.lang.ruby)
  • Re: method call on result of method call
    ... Let's say i want to invoke a method on an object, ... String newstring = mystring.charAt.toUpperCase; ... an object, we write the reference to the object, a dot, the method name, ... The generated code must dereference ...
    (comp.lang.java.help)
  • Re: Prematurely garbage collection
    ... In the example below, when Invoke is being executed, the reference of the instance is available with app root - so the object is not collected until there are no more pending references. ... Executing the example given by Jon below on my machine gave the following output: ... static void Main ...
    (microsoft.public.dotnet.framework.clr)
  • Re: How to convert this Vb code to Netcobol Code
    ... Dim slice ... This is equivalent to a COBOL "object reference" and establishes a pointer ... 01 cube OBJECT REFERENCE IMicrocube. ... The docs should show what methods ContourCubeX1 can invoke and there should ...
    (comp.lang.cobol)