[IronPython] Willing to pay for help

Dino Viehland dinov at microsoft.com
Fri May 28 01:14:49 CEST 2010


Another way to do this, and one I think you were trying to accomplish, and 
is probably superior, would be to move this to another thread.  In your code 
you have:

				#t = Thread(ThreadStart(CreateZip(zipname, fname)))
				#t.Start()

Which I believe is where you're trying to do this.  I would recommend moving
the whole loop into its own function (probably defined in your Button3Click
method so it just closes over the variables) such as:

	def Button3Click(...):
		...
   	      def inner_func(unused):
		    for fname in file_list:
			  ...

from System.Threading import ThreadPool
ThreadPool.QueueUserWorkItem(inner_function)

Then you just need to change your updates to the UI to be posted back on the
UI thread.  You do this using Control.BeginInvoke such as:

   	      def inner_func(unused):
		    for fname in file_list:
			  ...
		        def update_text():
                        self._label4.Text = "Zipping file " + str(count) + " of " + str(len(file_list))	

			  self.BeginInvoke(Action(update_text))

This will have the added benefit of never hanging - even if the zip operation
is taking a very long period of time.  You'll need to do the same thing for
updating the progress bar, and you'll need to flow in the value in 
self._textBox2.Text, etc...  Basically you can't touch the UI from any thread
other than the UI thread.

All of this was compiled w/ Outlook so hopefully it's mostly accurate and can
get you going in the right direction if you want a slightly better solution.

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of robinsiebler
> Sent: Thursday, May 27, 2010 1:25 PM
> To: users at lists.ironpython.com
> Subject: Re: [IronPython] Willing to pay for help
> 
> 
> That worked! Give me an e-mail address and I will send you the money.
> Can you
> recommend a good book to learn about WinForms and .NET in general?
> 
> 
> Curt Hagenlocher wrote:
> >
> > You almost certainly need to be pump messages occasionally if you're
> going
> > to be performing a long operation on the UI thread. With Windows
> Forms,
> > this
> > involves calling System.Windows.Forms.Application.DoEvents().
> >
> > On Thu, May 27, 2010 at 11:55 AM, robinsiebler <robinsiebler at 321.net>
> > wrote:
> >
> >>
> >> This is my 1st IronPython/.NET app. It is really simple, all it does
> is
> >> zip
> >> all the files in a folder into an archive, 1 file per zip.
> >>
> >> The problem is that when it is zipping large files 200MB+ the app
> stops
> >> responding. It is still zipping files, but the UI doesn't update. I
> don't
> >> know how to fix this.
> >>
> >> The project is here -
> >>
> >> http://cid-
> 0c375b07f1f323b6.skydrive.live.com/self.aspx/.Public/ZipfilesGUI.zip
> >>
> >> I've looked at all the examples and I am can't seem to figure out
> how to
> >> apply them to my app. I'm sur that if someone shows me how to do it
> I
> >> will
> >> get it.
> >>
> >> I am willing to pay $30 to anyone who will help me solve the
> problem.
> >> The
> >> problem is this - when zipping large files (100MB+) the UI stops
> >> responding.
> >> It doesn't refresh until all the files are zipped.
> >> --
> >> View this message in context:
> >> http://old.nabble.com/Willing-to-pay-for-help-
> tp28698448p28698448.html
> >> Sent from the IronPython mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at lists.ironpython.com
> >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >>
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
> 
> --
> View this message in context: http://old.nabble.com/Willing-to-pay-for-
> help-tp28698448p28699466.html
> Sent from the IronPython mailing list archive at Nabble.com.
> 
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list