Hi John,

>  You might consider amending your example on the wiki page and insert some
> conditional compilation steps for j602 and beyond.
Oh, this was the main reason why I wrote the guide J VB.NET which can be found 
here --> http://www.jsoftware.com/jwiki/Guides/J%20VB.NET

It was originally intended as a guide for Visual Studio Express 2008 for C# 
with J602 ... but I reasoned that C# and VB.NET were so similar that why not do 
it in VB.NET. Hehehehe. I usually irritate my wife when I reason things out 
this way.  Bwahahahahah (my world domination laugh). 

> The only issue with the fake invisible J window is a very brief visible
> flicker during server startup.  This may be something J implementers might
> want to take a look at.
I seem to remember this flicker ... I believe this is caused by two windows 
being drawn one after the other. It seems that there is an window created when 
the profile script is execute then it is unloaded and your new J session window 
is create with the wd command. Not so sure though. 

Oh, about C# garbage collector, I usually create my J wrapper class from an 
instance of the IDisposable interface ... like so:
using System;
using System.Collections.Generic;
using System.Text;
using JEXEServerLib;
using SmartEOE.Properties;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace SmartEOE
{
    public class Session : IDisposable
    {
        /// <summary>
        /// Holds the instance of the J Object
        /// </summary>
        private JEXEServerClass jObject;
//
// ... snip ...
//
        /// <summary>
        /// Use C# destructor syntax for finalization code.
        /// This destructor will run only if the Dispose method 
        /// does not get called.
        /// It gives your base class the opportunity to finalize.
        /// Do not provide destructors in types derived from this class.
        /// </summary>
        ~Session()
        {
            // Do not re-create Dispose clean-up code here.
            // Calling Dispose(false) is optimal in terms of
            // readability and maintainability.
            Dispose(false);
        }

        /// <summary>
        /// Implement IDisposable.
        /// Do not make this method virutal.
        /// A derived class should not be able to overrride this method.
        /// </summary>
        public void Dispose()
        {
            Dispose(true);
            // This object will be cleaned up by the Dispose method.
            // Therefore, you should call GC.SupressFinalize to 
            // take this object off the finalization queue
            // and prevent finalization code for this object 
            // from executing the second time.
            GC.SuppressFinalize(this);
        }

        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the 
        /// runtime from inside the finalizer and you should not reference 
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed 
                // and unmanaged resources.
                if (disposing)
                {
                    try
                    {
                        if (jObject != null)
                        {
                            Marshal.FinalReleaseComObject(jObject);
                        }
                    }
                    catch
                    {
                        // DONT DO ANYTHING ;)
                    }
                }

                // Force garbage collection
                GC.Collect();
            }
            disposed = true;
        }
    }
}

I would suggest further reading of the IDisposable interface. :)

Just happy you got it to work.

r/Alex

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of John Baker
Sent: Thursday, August 13, 2009 10:44 AM
To: Programming forum
Subject: Re: [Jprogramming] C# and JEXEServer

Thanks  Alex,

It's coherent answers like this that make this group such a pleasure.

After cutting out bits of your code I was able to get the JEXEServer showing
and shutting down properly.  The trick with shutdown is to let C#'s garbage
collector take out the trash.

You might consider amending your example on the wiki page and insert some
conditional compilation steps for j602 and beyond.

The only issue with the fake invisible J window is a very brief visible
flicker during server startup.  This may be something J implementers might
want to take a look at.

Thanks again.


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to