Page 1 of 1

the problem in create f_in_box form at multithreading

Posted: Mon Mar 30, 2009 7:07 am
by alpha
hi,can anybody help me?
when i create a common form at work thread(not main thread),it works like this:

Code: Select all

Form1 form = new Form1();
ISynchronizeInvoke synchronizer;
synchronizer = form;
MethodInvoker invoker = new MethodInvoker(form.Show);
Global.mainForm.Invoke(invoker, null);


but,if the Form1 extend f_in_box__lib.f_in_box__form,it doesn‘t work.


why?

Posted: Mon Mar 30, 2009 8:09 am
by Softanics
Thank you for your question.

Could you please send me a sample to test to support (at) f-in-box.com ?

Thank you.

Posted: Tue Mar 31, 2009 12:59 am
by alpha
The thread was create by quartz(.net),I want to show a new flash form within a work thread.like this:

Code: Select all

class WidgetJob : IJob
    {
         public virtual void Execute(JobExecutionContext context) {
            try {
                JobDataMap data = context.JobDetail.JobDataMap;
            //string xml = data.GetString("swf");            
         
            
            Form1 form = new Form1();
            ISynchronizeInvoke synchronizer;
            synchronizer = form;
            MethodInvoker invoker = new MethodInvoker(form.Show);
            Global.mainForm.Invoke(invoker, null);

            } catch (JobExecutionException e) {
                throw new NotImplementedException();
            }
        }
      
    }


the quartz configure like this:
properties["quartz.scheduler.instanceName"] = "PriorityExampleScheduler";
properties["quartz.threadPool.threadCount"] = "1";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.jobStore.type"] = "Quartz.Simpl.RAMJobStore, Quartz";

Posted: Tue Mar 31, 2009 1:51 pm
by Softanics
So Form1 form is created in one thread and form.Show is called from another, right?

Thank you.

Posted: Wed Apr 01, 2009 2:09 am
by alpha
Yes,it is. the instance of WidgetJob was create by quartz.net and run in a single thread,but it is not the message queue thread.so,if I want to show the form ,I must invoke the form.Show() method in the message queue thread. But it seems that when a flashform extend f_in_box__form,it auto show without flashform.Show() method.(the flashform.Show() do nothing?) ,
therefore, the question arises。

here some info;
http://www.codeproject.com/KB/cs/threadsafeforms.aspx

Posted: Wed Apr 01, 2009 1:23 pm
by Softanics
But you call

Form1 form = new Form1();

not using Global.mainForm.Invoke...