I want to add a status window to my programm. Since there are times,
when my program works quite a while, I want to give him status
information with this. Furthermore I want to give him the chance to
cancel whenever he wants to.

I basically have two problems on which I am unable to find something
really helpful about.

The general structure of my program is like this:
main calls upon several functions e.g. emailextractor.get_email.
emailextractor.get_email does the same e.g. it calls upon
Both convert and get_email return an object.

In main and in emailextractor I want to give status information to the
user. e.g.
get_email{ ...
info.value = "converting..."
var other_email = emailconverter.convert(this.email);
return other_email;
main looks similar:
{ ...
info.value = "login..."
other_email = emailextractor.get_email();

Now I have a problem, that the message only gets updated, when I ask
for user actions, which is a bit late. I read that I should use
setTimeout(func,msec); so I tried two possibilities, of which both
didn't work for me:
1) all what follows in func and usage of a callback

info.value = "converting..."
return this.email;

other_email = emailconverter.convert(email);
return other_email;

other_email = emailextractor.get_email();
other_email = func(other_email);
While that worked in itself, it did not solve the lagging problem. I
still got the old message and not "converting...".

2) much shorter; func is an empty function, because basically I don't
care if the programm already starts converting. I just want the value
to be updated:
info.value = "converting..."
var other_email = emailconverter.convert(this.email);
return other_email;


Didn't work either.
So I'm not sure what I'm doing wring here...

The second problem I have with the status window is that it has a
cancel button. And if I click that I want to end the whole program.
I tried it with if(!info) return null; or if(!info) return -1,
depending on the function I was in.
But when I click on the button, it closes the window (eventually), but
info itself is still there, even though I only gave the reference
further. Since info is still there it doesn't close the window
I think I could use an onClick-Event. But then I don't know how to
affect the other thread especially closing it.

I appreciate any kind of help here. I basically want it to look like
the status window, when you sent an email (not the bar though), but
Mozilla uses nsIWebProgressListener there, which is only for
asynchronous requests and mine should be over the whole program.