I havent played much with threading and Im testing stuff out with a little
space invaders game. My Invader class has a StopInvader StartInvader and
Invade subs.
There is a class level variable called Alive of Type Boolean.
On StartInvader I begin a new thread at the address of Invade and inside
this While Alive . . . . . . . Do Stuff ( Move etc ) Wend.
Stop invalder simply sets Alive to False.
OK
So the start starts it OK, and it shoots across the screeen, Fine; Stop
Stops the Invade, however, StartInvader only works the first time,
any ideas ? ( Excuse any bad programming as Im only playing )
Public Class Invader
Private invaderImage As Image
Private invaderImageDel ete As Image
Private space As Graphics
Private startPoint As Point
Private currentPoint As New Point
Private Enum direction
left
right
End Enum
Private invaderDirectio n As direction
Private alive As Boolean = True
Private parentForm As Form1
Private invadeThread As Threading.Threa d
Public Sub New(ByVal iSpace As Graphics, ByVal refForm As Form1, ByVal
iInvader As String, ByVal iInvaderDelete As String)
space = iSpace
invaderDirectio n = direction.right
startPoint = New Point(10, 10)
parentForm = refForm
invaderImage = Image.FromFile( iInvader)
invaderImageDel ete = Image.FromFile( iInvaderDelete)
End Sub
Public Sub startInvader()
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
parentForm.newG ameButton.Enabl ed = False
parentForm.stop GameButton.Enab led = True
invadeThread = New Threading.Threa d(AddressOf invade)
invadeThread.Is Background = True
invadeThread.St art()
End Sub
Public Sub stopInvader()
parentForm.newG ameButton.Enabl ed = True
parentForm.stop GameButton.Enab led = False
alive = False
End Sub
Private Sub Fire()
End Sub
Private Sub invade()
While alive
If currentPoint.X > space.VisibleCl ipBounds.Width Then
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
End If
Threading.Threa d.CurrentThread .Sleep(20)
space.DrawImage (MyClass.invade rImageDelete, currentPoint)
currentPoint.X += 5
space.DrawImage (MyClass.invade rImage, currentPoint)
End While
End Sub
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
-- 10 1095
Instead of "stop" try "sleep".
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in
message news:#2******** ******@TK2MSFTN GP12.phx.gbl: I havent played much with threading and Im testing stuff out with a little
space invaders game. My Invader class has a StopInvader StartInvader and
Invade subs.
There is a class level variable called Alive of Type Boolean.
On StartInvader I begin a new thread at the address of Invade and inside
this While Alive . . . . . . . Do Stuff ( Move etc ) Wend.
Stop invalder simply sets Alive to False.
OK
So the start starts it OK, and it shoots across the screeen, Fine; Stop Stops the Invade, however, StartInvader only works the first time,
any ideas ? ( Excuse any bad programming as Im only playing )
Public Class Invader
Private invaderImage As Image
Private invaderImageDel ete As Image
Private space As Graphics
Private startPoint As Point
Private currentPoint As New Point
Private Enum direction
left
right
End Enum
Private invaderDirectio n As direction
Private alive As Boolean = True
Private parentForm As Form1
Private invadeThread As Threading.Threa d Public Sub New(ByVal iSpace As Graphics, ByVal refForm As Form1, ByVal iInvader As String, ByVal iInvaderDelete As String)
space = iSpace
invaderDirectio n = direction.right
startPoint = New Point(10, 10)
parentForm = refForm
invaderImage = Image.FromFile( iInvader)
invaderImageDel ete = Image.FromFile( iInvaderDelete)
End Sub
Public Sub startInvader()
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
parentForm.newG ameButton.Enabl ed = False
parentForm.stop GameButton.Enab led = True
invadeThread = New Threading.Threa d(AddressOf invade)
invadeThread.Is Background = True
invadeThread.St art()
End Sub Public Sub stopInvader()
parentForm.newG ameButton.Enabl ed = True
parentForm.stop GameButton.Enab led = False
alive = False
End Sub
Private Sub Fire()
End Sub
Private Sub invade()
While alive
If currentPoint.X > space.VisibleCl ipBounds.Width Then
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
End If
Threading.Threa d.CurrentThread .Sleep(20)
space.DrawImage (MyClass.invade rImageDelete, currentPoint)
currentPoint.X += 5
space.DrawImage (MyClass.invade rImage, currentPoint)
End While
End Sub
Just a guess - You're setting alive to false when calling StopInvader which
is never being set to true again which is why the second time Invade just
skips the entire while loop. Or did I overlook something :)??
Imran.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. I havent played much with threading and Im testing stuff out with a little space invaders game. My Invader class has a StopInvader StartInvader and Invade subs.
There is a class level variable called Alive of Type Boolean.
On StartInvader I begin a new thread at the address of Invade and inside this While Alive . . . . . . . Do Stuff ( Move etc ) Wend.
Stop invalder simply sets Alive to False.
OK
So the start starts it OK, and it shoots across the screeen, Fine; Stop Stops the Invade, however, StartInvader only works the first time,
any ideas ? ( Excuse any bad programming as Im only playing )
Public Class Invader
Private invaderImage As Image
Private invaderImageDel ete As Image
Private space As Graphics
Private startPoint As Point
Private currentPoint As New Point
Private Enum direction
left
right
End Enum
Private invaderDirectio n As direction
Private alive As Boolean = True
Private parentForm As Form1
Private invadeThread As Threading.Threa d Public Sub New(ByVal iSpace As Graphics, ByVal refForm As Form1, ByVal iInvader As String, ByVal iInvaderDelete As String)
space = iSpace
invaderDirectio n = direction.right
startPoint = New Point(10, 10)
parentForm = refForm
invaderImage = Image.FromFile( iInvader)
invaderImageDel ete = Image.FromFile( iInvaderDelete)
End Sub
Public Sub startInvader()
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
parentForm.newG ameButton.Enabl ed = False
parentForm.stop GameButton.Enab led = True
invadeThread = New Threading.Threa d(AddressOf invade)
invadeThread.Is Background = True
invadeThread.St art()
End Sub Public Sub stopInvader()
parentForm.newG ameButton.Enabl ed = True
parentForm.stop GameButton.Enab led = False
alive = False
End Sub
Private Sub Fire()
End Sub
Private Sub invade()
While alive
If currentPoint.X > space.VisibleCl ipBounds.Width Then
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
End If
Threading.Threa d.CurrentThread .Sleep(20)
space.DrawImage (MyClass.invade rImageDelete, currentPoint)
currentPoint.X += 5
space.DrawImage (MyClass.invade rImage, currentPoint)
End While
End Sub -- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1) Next Process.Start(" mailto:" & New String(ch)) --
Imran was correct, but thanks for answering
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"scorpion53 061" <ad***@nospamhe rekjmsolutions. com> wrote in message
news:OC******** ******@TK2MSFTN GP09.phx.gbl... Instead of "stop" try "sleep". "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message news:#2******** ******@TK2MSFTN GP12.phx.gbl: I havent played much with threading and Im testing stuff out with a little
space invaders game. My Invader class has a StopInvader StartInvader and
Invade subs.
There is a class level variable called Alive of Type Boolean.
On StartInvader I begin a new thread at the address of Invade and inside
this While Alive . . . . . . . Do Stuff ( Move etc ) Wend.
Stop invalder simply sets Alive to False.
OK
So the start starts it OK, and it shoots across the screeen, Fine; Stop Stops the Invade, however, StartInvader only works the first time,
any ideas ? ( Excuse any bad programming as Im only playing )
Public Class Invader
Private invaderImage As Image
Private invaderImageDel ete As Image
Private space As Graphics
Private startPoint As Point
Private currentPoint As New Point
Private Enum direction
left
right
End Enum
Private invaderDirectio n As direction
Private alive As Boolean = True
Private parentForm As Form1
Private invadeThread As Threading.Threa d Public Sub New(ByVal iSpace As Graphics, ByVal refForm As Form1, ByVal iInvader As String, ByVal iInvaderDelete As String)
space = iSpace
invaderDirectio n = direction.right
startPoint = New Point(10, 10)
parentForm = refForm
invaderImage = Image.FromFile( iInvader)
invaderImageDel ete = Image.FromFile( iInvaderDelete)
End Sub
Public Sub startInvader()
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
parentForm.newG ameButton.Enabl ed = False
parentForm.stop GameButton.Enab led = True
invadeThread = New Threading.Threa d(AddressOf invade)
invadeThread.Is Background = True
invadeThread.St art()
End Sub Public Sub stopInvader()
parentForm.newG ameButton.Enabl ed = True
parentForm.stop GameButton.Enab led = False
alive = False
End Sub
Private Sub Fire()
End Sub
Private Sub invade()
While alive
If currentPoint.X > space.VisibleCl ipBounds.Width Then
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
End If
Threading.Threa d.CurrentThread .Sleep(20)
space.DrawImage (MyClass.invade rImageDelete, currentPoint)
currentPoint.X += 5
space.DrawImage (MyClass.invade rImage, currentPoint)
End While
End Sub
Bang On - I just didnt see it ( What an idiot I am )
Thanks
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Imran Koradia" <no****@microso ft.com> wrote in message
news:ub******** ******@TK2MSFTN GP10.phx.gbl... Just a guess - You're setting alive to false when calling StopInvader which is never being set to true again which is why the second time Invade just skips the entire while loop. Or did I overlook something :)??
Imran.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..I havent played much with threading and Im testing stuff out with a little space invaders game. My Invader class has a StopInvader StartInvader and Invade subs.
There is a class level variable called Alive of Type Boolean.
On StartInvader I begin a new thread at the address of Invade and inside this While Alive . . . . . . . Do Stuff ( Move etc ) Wend.
Stop invalder simply sets Alive to False.
OK
So the start starts it OK, and it shoots across the screeen, Fine; Stop Stops the Invade, however, StartInvader only works the first time,
any ideas ? ( Excuse any bad programming as Im only playing )
Public Class Invader
Private invaderImage As Image
Private invaderImageDel ete As Image
Private space As Graphics
Private startPoint As Point
Private currentPoint As New Point
Private Enum direction
left
right
End Enum
Private invaderDirectio n As direction
Private alive As Boolean = True
Private parentForm As Form1
Private invadeThread As Threading.Threa d Public Sub New(ByVal iSpace As Graphics, ByVal refForm As Form1, ByVal iInvader As String, ByVal iInvaderDelete As String)
space = iSpace
invaderDirectio n = direction.right
startPoint = New Point(10, 10)
parentForm = refForm
invaderImage = Image.FromFile( iInvader)
invaderImageDel ete = Image.FromFile( iInvaderDelete)
End Sub
Public Sub startInvader()
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
parentForm.newG ameButton.Enabl ed = False
parentForm.stop GameButton.Enab led = True
invadeThread = New Threading.Threa d(AddressOf invade)
invadeThread.Is Background = True
invadeThread.St art()
End Sub Public Sub stopInvader()
parentForm.newG ameButton.Enabl ed = True
parentForm.stop GameButton.Enab led = False
alive = False
End Sub
Private Sub Fire()
End Sub
Private Sub invade()
While alive
If currentPoint.X > space.VisibleCl ipBounds.Width Then
currentPoint.X = startPoint.X
currentPoint.Y = startPoint.Y
End If
Threading.Threa d.CurrentThread .Sleep(20)
space.DrawImage (MyClass.invade rImageDelete, currentPoint)
currentPoint.X += 5
space.DrawImage (MyClass.invade rImage, currentPoint)
End While
End Sub -- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1) Next Process.Start(" mailto:" & New String(ch)) --
Do we get it when it is ready?
Cor
good question Cor :)
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. .. Do we get it when it is ready?
Cor
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:uQ******** ********@TK2MSF TNGP10.phx.gbl. .. Bang On - I just didnt see it ( What an idiot I am )
naah - maybe you just a little break :)
LOL, for what its worth, yes, i would be happy to post it.
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Imran Koradia" <no****@microso ft.com> wrote in message
news:Oj******** *****@TK2MSFTNG P09.phx.gbl... good question Cor :)
"Cor Ligthert" <no************ @planet.nl> wrote in message news:%2******** ********@TK2MSF TNGP15.phx.gbl. .. Do we get it when it is ready?
Cor
I was just guessing. I didn't have time to pull your code part.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in
message news:uS******** ******@TK2MSFTN GP12.phx.gbl: Imran was correct, but thanks for answering This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Anthony_Barker |
last post by:
I have been reading a book about the evolution of the Basic
programming language. The author states that Basic - particularly
Microsoft's version is full of compromises which crept in along the
language's 30+ year evolution.
What to you think python largest compromises are?
The three that come to my mind are significant whitespace, dynamic
typing, and that it is interpreted - not compiled. These three put
python under fire and cause...
|
by: Egor Bolonev |
last post by:
hi all
my program terminates with error i dont know why it tells 'TypeError:
run() takes exactly 1 argument (10 given)'
=program====================
import os, os.path, threading, sys
def get_all_files(path):
"""return all files of folder path, scan with subfolders
|
by: aurora |
last post by:
Hello!
Just gone though an article via Slashdot titled "The Free Lunch Is Over: A
Fundamental Turn Toward Concurrency in Software"
http://www.gotw.ca/publications/concurrency-ddj.htm]. It argues that the
continous CPU performance gain we've seen is finally over. And that future
gain would primary be in the area of software concurrency taking advantage
hyperthreading and multicore architectures.
Perhaps something the Python interpreter...
|
by: dan baker |
last post by:
I have a page that gets loaded with a meta-refresh hardcoded so that a
few things on the page get updated. its kind of a fake chat board.
anyway, what I need to do is turn off the meta-refresh once someone
clicks in a <textarea> to enter their input; otherwise the refresh
catches them in the middle and messes up the focus.
I need a way to turn off the meta-refresh, or to force the
cursor/focus to stay in the message input box once they...
|
by: Jon Skeet [C# MVP] |
last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the
article on all the groups this is posted to.
I've finally managed to finish my article on multi-threading - at least
for the moment. I'd be *very* grateful if people with any interest in
multi-threading would read it (even just bits of it - it's somewhat
long to go through the whole thing!) to check for accuracy,
effectiveness of examples, etc.
Feel free to mail...
| |
by: CK |
last post by:
I have the following code in a windows service, when I start the windows
service process1 and process2 work fine , but final process (3) doesnt get
called. i stop and restart the windows service and the final process(3) gets
called. what am I doing wrong with the threading? by the way
Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from
process 1.
Thanks
1)
|
by: Vjay77 |
last post by:
In this code:
Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not (Me.downloadUrlTextBox.Text = "")
Then
Me.outputGroupBox.Enabled = True
Me.bytesDownloadedTextBox.Text = ""
Me.totalBytesTextBox.Text = ""
|
by: Jamie Risk |
last post by:
I'm attempting to improve some serially executing code (that
uses the SerialPort class) bogging Windows down when it runs.
To do the 'antibogging' I'm following the example from MSDN
Windows.IO.Ports.SerialPort page and use threading.
I'm not sure if I'm creating problems with this implementation
and would appreciate your input.
The original serial code:
{
|
by: Mike P |
last post by:
I am trying to write my first program using threading..basically I am
moving messages from an Outlook inbox and want to show the user where
the process is up to without having to wait until it has finished. I am
trying to follow this example :
http://www.codeproject.com/cs/miscctrl/progressdialog.asp
But although the messages still get moved, the progress window never
does anything. Here is my code in full, if anybody who knows...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |