Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 27 of 32 1 2 25 26 27 28 29 31 32
Re: C# wrapper - RELEASE [Re: Joozey] #317685
04/01/10 20:29
04/01/10 20:29
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
@ventilator
this looks great, i like how the code needed for the lambda expression is shorter than my attempt !
The handling of the updating process itself doesn't pose problem, only the usage for the user did ^^

@Joozey
i had a quick look at the wrapper and think this could indeed be possible !
edit : I'll try to implement the wrapper, without using any unsafe instructions - so far I was able to do this ^^

@all
should the wrapper use double or float instead of Var ?

Last edited by Stromausfall; 04/02/10 09:55.

get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #317694
04/01/10 20:47
04/01/10 20:47
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
yes, floats are cheaper but i think this only really matters for heavy number crunching. probably it doesn't make much difference for passing some numbers around.

(in python there only are doubles. single precision floats don't exist.)

so i think doubles are fine but i also wouldn't mind the needed f that much.

Re: C# wrapper - RELEASE [Re: ventilator] #318053
04/04/10 17:45
04/04/10 17:45
Joined: Sep 2003
Posts: 55
D
DarkPhantom Offline
Junior Member
DarkPhantom  Offline
Junior Member
D

Joined: Sep 2003
Posts: 55
you should use double instead of float. the floatingpoint unit in the cpu converts floats always to double. double needs as double as much memory as a float. but i think that doesnt matter that much because textures, models etc need around 90% of used memory


Sorry for my bad english
Re: C# wrapper - RELEASE [Re: DarkPhantom] #318056
04/04/10 18:28
04/04/10 18:28
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
I didn't knew that, that should clarify the question if double or float should be preferred ^^


get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #318059
04/04/10 18:57
04/04/10 18:57
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Hi, I'm sometimes getting the exception 'Collection was modified after the enumerator was instantiated.' at the line...
'while (AddToScheduleListEnumerator.MoveNext() == true)'.

This is in the function 'AddToScheduleList' of 'Scheduler.cs'.

Any ideas what events could cause this to happen, and any possible workarounds?

Last edited by DJBMASTER; 04/04/10 18:57.
Re: C# wrapper - RELEASE [Re: DJBMASTER] #318075
04/04/10 20:27
04/04/10 20:27
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
I'll have a look at it, it seems like there's some inconsistency in the scheduler...

do you happen to have an example of a program that causes such a crash - or any guess, which events or function seem to cause this problem more often ?

edit :
do you use two threads in your program ? because i think that this problem could arise if the "engine"-thread (that iterates over the "yield return" functiosn) exists AND ANOTHER thread that somehow also tries to interact with that thread or the engine !

Last edited by Stromausfall; 04/04/10 20:30.

get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #318079
04/04/10 21:01
04/04/10 21:01
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Ermm well first I use 'engine_open' to load the engine and then once the 'hWnd' variable is available, I use some win32 functions to embed the engine into my form.

Whenever I want to interact with the engine I use a seperate function (IEnumerable type) and call 'Scheduler.AddEventVoid(FunctionName)'.

So yes there is probably the 'engine' thread and the 'form' thread. I have however used 'yeild return Scheduler.PROC_MODE.PROC_EARLIEST' at the beginning of most functions. I thought this would allow a 'gap' into the engine processing.

There does seem to be some synchronisation issue though, because it is a very random bug.

You could maybe re-create this scenario but using the 'windows embed' demo I submitted, and from the form try to change something in the engine multiple times, like a random screen color, etc; to see if you get synchronisation problems.

Last edited by DJBMASTER; 04/04/10 21:05.
Re: C# wrapper - RELEASE [Re: DJBMASTER] #318081
04/04/10 21:06
04/04/10 21:06
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
thank you for your detailed explanation - they are invaluable to detect the cause of the problem !!
the situation you mentioned, seems to be the exact reason, why this bug occurs ! You add a thread to the scheduler (regardless of the priority of the function like Scheduler.PROC_MODE.PROC_EARLIEST), while this one is maybe just iterating over the list to which you add the function -> this causes the crash !
I will have a look at it and see if i can create a quick hotfix for the wrapper, which adds some kind of "thread-safe" - Scheduler.AddEventVoid(FunctionName) function - which should prevent this problem !

edit :

I've uploaded a new version of the wrapper : 1.0.2 (big thanks go to DJBMASTER for providing me with the needed details to solve this problem !!), that now includes a method named AddEventVoidThreadSafe that is the thread safe variant of the method AddEventVoid !
Whenever you don't need AddEventVoidThreadSafe, use AddEventVoid, as methods added through AddEventVoidThreadSafe aren't executed immediately, but may take up to one frame to execute - so only use AddEventVoidThreadSafe if you access the scheduler from another thread !

I've used the following code to test this new function :
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections;

using AcknexWrapper;

using System.Threading;

namespace OldWrapperTestApp
{
    class Program
    {
        private static DateTime StartTime = DateTime.Now;

        static IEnumerable bla()
        {
            yield return 1;
        }

        static void dummyFun()
        {
            Thread.Sleep(1000);
            while (true)
            {
                Console.WriteLine(DateTime.Now - StartTime);
                Scheduler.AddEventVoidThreadSafe(bla);
                //Scheduler.AddEventVoid(bla);
                Thread.Sleep(2);
            }
        }

        static void Main(string[] args)
        {
            EngFun.engine_open(null);
            EngFun.level_load(null);

            Thread t = new Thread(dummyFun);
            t.Start();

            Scheduler.StartScheduler(bla);

        }
    }
}



and I've got the following results :
Code:
AddEventVoid

1.)  00:00:16.4375000 - crash
2.)  00:00:40.8750000 - crash
3.)  00:00:04.4375000 - crash
4.)  00:00:04.2968750 - crash
5.)  00:06:12.2968750 - crash
6.)  00:00:03.3750000 - crash
7.)  00:00:45.0781250 - crash
8.)  00:00:05.2968750 - crash
9.)  00:00:07.7031250 - crash
10.) 00:00:14.4687500 - crash

AddEventVoidThreadSafe

1.) ~ 00:02:30 - aborted by user - no crash
2.) ~ 00:02:45 - aborted by user - no crash
3.) ~ 00:02:30 - aborted by user - no crash
4.) ~ 00:03:00 - aborted by user - no crash
5.) ~ 00:02:30 - aborted by user - no crash



Last edited by Stromausfall; 04/04/10 22:44.

get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #328625
06/14/10 12:05
06/14/10 12:05
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
For some reason Visual C# can't open the acknex.dll, can't get it to work. Any ideas? Tried to copy the dll everywhere, did the post-build event exactly as described, but no results.


Click and join the 3dgs irc community!
Room: #3dgs
Re: C# wrapper - RELEASE [Re: Joozey] #328628
06/14/10 12:27
06/14/10 12:27
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
hmm, when you build your application does the WED dialog popup and display 'acknex.dll'?

It will then be copied to the same directory as your exe.

Page 27 of 32 1 2 25 26 27 28 29 31 32

Moderated by  TWO 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1