Freigeben über


Small Basic - Synchronous and Asynchronous Type Operations

The challenge of this month has Multitasking Challenge.  In Small Basic, there are two types of operations.  One is synchronous type, the other is asynchronous type.  Most of operations are synchronous type that wait the operations done before starting the next step.  But some operations are asynchronous type that don't wait the operations done.

Asynchronous Type Operations

Following operations are asynchronous type:

  • Shape.Animation()
  • Sound.Play()
  • Sound.PlayBellRing()
  • Sound.PlayChime()
  • Sound.PlayChimes()
  • Sound.PlayClick()

Synchronous Type Operations

Other operations than listed above are synchronous type.  Especially, following operations may need much time.

  • File.ReadContents()
  • Flickr.GetRandomPicture()
  • ImageList.LoadImage()
  • Network.GetWebPageContents()
  • Sound.PlayMusic()
  • Turtle.Move()

If you want to do something while running synchronous type operations, you should use events such as timer, mouse, keyboard or controls events.  On the other side, be careful to use these slow asynchronous type operations in an event handler subroutine.  The next event will occur while running the last event handler.

Comments

  • Anonymous
    September 13, 2016
    Very interesting article, like always :)What I want most in the world, is that programmers of Small Basic, those who have designed this program, they can improve the command : ' ' sound.playmusic ' ' in order to put it in the Asynchronous category.Just because, you remember when i tried to make a slideshow in SBasic with music in the background, the music could'nt simply not follow the slides change images.In many cases, soundplay.music should be in the Asynchrome category, so a few video games made in Small Basic would gain to.Hoping that version 1.3 of SB can do this improve :)
    • Anonymous
      September 13, 2016
      The comment has been removed
  • Anonymous
    September 15, 2016
    @litdevyes, Great !! it works !! asynchronous music with imageshere a preview of a test slides show with music' program YLed' Sept 15th 2016' slide show with music asynchronous' program no: SGZ504