TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
davidh1
NA
19
0
Threading and Direct X 7
Oct 28 2003 4:46 PM
I am using C# and DirectX7 (in DxVBLib) to create a tiled game editor / interpreter. It allocates a "GameData" object that contains the current game data. I want to have an independent window that shows the "current" view of the game data. For this, I created a ViewForm class, which I allocate with new and call ".Show" on. This invoked the load event on this form. Once created, I have a function in ViewForm that loops. It paints the game onto a backbuffer and flips it onto the primary buffer using Direct X 7 . I want to call this function when I click on a button on my main form. The way I have it, is that the click event on MainForm invokes myGameData.displayGame(), which in turn invokes myGameData.myViewForm.startApp() which is a loop that displays the game field at a fixed frames-per-second rate. W/out threading, the loop paints a DirectX backbuffer and then flips it into the primary buffer. Because it is not multi threaded, the loop doesn't end, so I have to call Application.DoEvents() to keep the two windows from hanging until the call ends. What I want to do is to put the whole displayGame() call into a thread. The problem is when I do, the DirectX calls fail. It looks like it looses the DirectX context or something. I did the basic thing: Thread t = new Thread( new ThreadStart(myViewForm.myLoop(ref myGameData))); t.Start(); I am allocating and initializing DirectX in the constructor for the ViewForm. Any ideas? Some questions: a) Should I initialize direct X inside the function (i.e. local to the thread?) b) If I want to have multiple instances of this DirectX stuff, will they interfeer with each other? I hope this makes sence. Dave
Reply
Answers (
1
)
sqldatareader in a thread
How do you kill a thread aside from abort()?