# Wxruby and rubymsn

**URL:** <https://www.ruby-forum.com/t/wxruby-and-rubymsn/179858>\
**Category:** Ruby\
**Created:** [December 5, 2009, 6:10pm UTC](https://www.ruby-forum.com/t/wxruby-and-rubymsn/179858 "2009-12-05T18:10:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomask](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@thomask](https://www.ruby-forum.com/u/thomask)\
**Post date:** [December 5, 2009, 6:10pm UTC](https://www.ruby-forum.com/t/wxruby-and-rubymsn/179858/1 "2009-12-05T18:10:56Z")

</div>

Hello I’m currently playing with wxRuby and RubyMSN to learn to program  
desktop-programs. I know it is a hard task instead of just crating a  
notepad etc, but I need a bigger task than a notepad.

I now do manage to use them by them self, but I cant get them to work  
together. The problem is the loop.

RubyMSN wants to have an endless loop like

while true  
sleep 1  
end

or using the GUI’s mainloop or something

I currently have this code as the loop

TheApp.new.main\_loop()  
while true  
sleep 1  
end

I have my window working, and the main\_loop doing something. But I cant  
log in, it’s like I doesn’t have any loop (from the tutorial), I only  
get one debug line. But as soon as I close the window and lets the  
endless loop do it’s job it works like a charm.

Someone ?

Duplicate at

> <https://stackoverflow.com/questions/1852273/wxruby-and-rubymsn>

---

<div class="post-metadata">

**Author:** ![thomask](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@thomask](https://www.ruby-forum.com/u/thomask)\
**Post date:** [December 5, 2009, 6:57pm UTC](https://www.ruby-forum.com/t/wxruby-and-rubymsn/179858/2 "2009-12-05T18:57:38Z")

</div>

answered on stackoverflow, here’s a copy for the sake of the rubytalk  
archive:

Worked for me. Try this: copy the minimal sample from the wxruby  
distribution, and modify minimal.rb so that you start your msn thread  
just before the wx main loop:

require ‘msn/msn’

conn = MSNConnection.new(“removed\_email\_address@domain.invalid”, “secretpassword123”)  
conn.start

# Wx::App is the container class for any wxruby app. To start an

# application, either define a subclass of Wx::App, create an instance,

# and call its main\_loop method, OR, simply call the Wx::App.run class

# method, as shown here.

Wx::App.run do  
self.app\_name = ‘Minimal’  
frame = MinimalFrame.new(“Minimal wxRuby App”)  
frame.show  
end

You’ll need to symlink the msn directory inside the minimal directory  
to get the require statement working, of course.

You don’t need the while true {sleep 1} loop; that’s just to prevent  
the program from exiting so that your msn thread can keep running. The  
wx main loop accomplishes the same purpose.

---

<div class="post-metadata">

**Author:** ![thomask](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@thomask](https://www.ruby-forum.com/u/thomask)\
**Post date:** [December 5, 2009, 8:05pm UTC](https://www.ruby-forum.com/t/wxruby-and-rubymsn/179858/3 "2009-12-05T20:05:41Z")

</div>

As I told in a comment:

Doesn’t seem to get any further.  
This is my code now: [pastie.org/729297](http://pastie.org/729297)

It still stops after

"–\> Sent: “VER 1 MSNP9 CVR0\r\n” "
