If I want to do some mutithread programming,how can I do using wxlua in pure lua? Thanks!
I search this maillist and found the mail thread discuss same condition: news://news.gmane.org:119/loo...@po... I would try to using luatask and wxPostEvent to wxlua main thread in another thread. On 2010年5月4日 21:43, Chunlin Zhang wrote: > If I want to do some mutithread programming,how can I do using wxlua in > pure lua? > Thanks! > > > ------------------------------------------------------------------------------
On Tue, May 4, 2010 at 9:43 AM, Chunlin Zhang <zha...@gm...> wrote: > If I want to do some mutithread programming,how can I do using wxlua in > pure lua? You can use Lua's coroutines, see the sample coroutine.wx.lua or more generally Google for sample code using Lua coroutines. wxThread will be added in the 2.9 release of wxLua, which may be in a few months. You can also see some coroutine usage in the program gpeddler2, it was written for a very old version of wxLua so it might not run out of the box, but wxLua hasn't changed too much. It at least might give you some ideas. http://www.erix.it/progutil/gpeddler2/help/gpeddler2.html Regards, John
On 2010年5月6日 1:39, John Labenski wrote: > On Tue, May 4, 2010 at 9:43 AM, Chunlin Zhang<zha...@gm...> wrote: >> If I want to do some mutithread programming,how can I do using wxlua in >> pure lua? > > You can use Lua's coroutines, see the sample coroutine.wx.lua or more > generally Google for sample code using Lua coroutines. wxThread will > be added in the 2.9 release of wxLua, which may be in a few months. Lua's coroutines can not solve my problem I think. My situation is that I have several thread(I use luatask,because coroutine I think it is not suitable here) to communicate with rs232 port,and when some data was send to wxlua main thread. At first I did not know how to receive data from other thread in main thread,so I thought I can new a wxthread to wait the data from other thread and then send event to wxlua main thread. Now I use the way that main thread handle the "wxEVT_IDLE",in this event handle I try to receive data.And it works > > You can also see some coroutine usage in the program gpeddler2, it was > written for a very old version of wxLua so it might not run out of the > box, but wxLua hasn't changed too much. It at least might give you > some ideas. > > http://www.erix.it/progutil/gpeddler2/help/gpeddler2.html > > Regards, > John > > ------------------------------------------------------------------------------
This is the link to the download page for gpeddler2. http://www.erix.it/progutil.html#gpeddler2 Regards, John On Wed, May 5, 2010 at 1:39 PM, John Labenski <jla...@gm...> wrote: > On Tue, May 4, 2010 at 9:43 AM, Chunlin Zhang <zha...@gm...> wrote: >> If I want to do some mutithread programming,how can I do using wxlua in >> pure lua? > > You can use Lua's coroutines, see the sample coroutine.wx.lua or more > generally Google for sample code using Lua coroutines. wxThread will > be added in the 2.9 release of wxLua, which may be in a few months. > > You can also see some coroutine usage in the program gpeddler2, it was > written for a very old version of wxLua so it might not run out of the > box, but wxLua hasn't changed too much. It at least might give you > some ideas. > > http://www.erix.it/progutil/gpeddler2/help/gpeddler2.html > > Regards, > John >
于 2010年05月14日 21:57, Chunlin Zhang 写道: > Now I use the way that main thread handle the "wxEVT_IDLE",in this event > handle I try to receive data.And it works > In linux(I use ubuntu),I found that wxEVT_IDLE only happy when mouse move in mainframe,so I have create a timer to run the function. ''' --idle event,continue to find message to handle again and again mainframe:Connect(wx.wxEVT_IDLE, function(event) mainframe_on_idle(mainframe,event) end) --in linux,wxEVT_IDLE only happy when mouse move in mainframe --so I create a timer for doing mainframe_on_idle local timer = wx.wxTimer(mainframe) mainframe:Connect(wx.wxEVT_TIMER, function(event) mainframe_on_idle(mainframe,event) end) timer:Start(800) '''
On Thu, Aug 19, 2010 at 1:25 AM, Chunlin Zhang <zha...@gm...> wrote: > 于 2010年05月14日 21:57, Chunlin Zhang 写道: >> Now I use the way that main thread handle the "wxEVT_IDLE",in this event >> handle I try to receive data.And it works >> > In linux(I use ubuntu),I found that wxEVT_IDLE only happy when mouse > move in mainframe,so I have create a timer to run the function. Note that you can also call wxIdleEvent::RequestMore(true) to get another idle event. Note that doing this uses 100% of the processor so be sure to call it only when you really are processing, but the application will be responsive. This is a standard way in wxWidgets to process something without using threads and have a cancel button usable. Regards, John Labenski