|
Quit cross posting. That is just flat out rude and doesn't get you any help.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hy there, I have a big problem. I need to play sounds(for now WAVs), more at a time. I have a method, because I used DirectSound3 on C++ and it worked. So I made a native dll that has 4 methods: one to initialize DirectSound, one to add a sound, one to play and one to stop.
The add methods looks like this:
[DllImport("playsound.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
public static extern void Add(string name,bool looped,IntPtr data);
At first,I had the wav sound in my application Resources(as an unmanaged memory stream), so I have done this:
data = new byte[Resource.win.Length];
Resource.sound.Read(data, 0, Resource.sound.Length);
handle = GCHandle.Alloc(data, GCHandleType.Pinned);
DirectSound.Add("soundname", false, handle.AddrOfPinnedObject());
The application seems to work fine. The sound does play. My problems started when I placed a button on the form.Even if the button doesn't do anything,pressing him increases app memory. When the application reaches a level(at my computer,aproximately 10 MB), the output shows "thread X exited with code.." and,from now on, the application is frozen,it blocks(at the method Play).
I suspect that the thread that exited was the garbage collector, and it messed up my sound.But I have a GCHandle on it...
When the method Add is called, the native dll(made in C++ Builder) uses new to create a buffer. Does .NET ignore that..and considers it unused memory?I can't tell .NET what is in that dll...because it is native. How do I stop him from taking that memory?
PS: If I load the sound directly from a file (!) the application does not froze,it just doesn't play the sound. Maybe because the resources are an object? So when the garbage collecter works,it compacts the memory?
If someone is fammiliar with this kind of problems, please help me, I am really stuck. Thans in advance.
|
|
|
|
|
From the code shown, it's impossible to determine the way you
are managing the lifetime of your objects.
What makes you think the GC is involved?
ctoma2005 wrote: When the method Add is called, the native dll(made in C++ Builder) uses new to create a buffer. Does .NET ignore that..and considers it unused memory?
The .NET framework doesn't know anything about that allocated memory. The memory
is allocated on whatever heap the new operator is using in the DLL code.
ctoma2005 wrote: data = new byte[Resource.win.Length];
Resource.sound.Read(data, 0, Resource.sound.Length);
I'm curious about this....why are different "Length"s used on these two lines?
Mark
|
|
|
|
|
Sorry, the wav was named(in my code), "win", I wanted to changed to "sound" so it has a more common name.
That's just it, the native dll holds a list of it's own of sounds that where added. So I don't really have objects. I am pretty sure that GC is involved, because GC has a background thread. I didn't start any threads. Plus, my sound does not play anymore, so the space the native dll allocated must not be there. The sound buffer is still there, as I placed a pinned handle on it. But how can I be sure that memory allocated by the native dll is not destroyed?
|
|
|
|
|
I think I found why the application is blocked. After I call the method Add(...), if I call GC.Collect() it freezes. I have no ideea why this is,I mean if .NET doesn't know anything about that memory, why can't it collect the unused objects?
|
|
|
|
|
Why are you calling Collect()?
The GC won't (and can't) do anything with the native memory blocks allocated in your native DLL.
The GC will eventually clean up managed objects that no longer have an outstanding reference.
It's up to you to manage the lifetime of your objects - both native and managed.
You have a problem somewhere obviously, but the GC should be irrelevant.
Mark
|
|
|
|
|
I'm not sure your marshaling is correct here...
What does the Add() function look like on the native side (it's prototype)?
Mark
|
|
|
|
|
Sorry, I have the code at work,I will put the signature tomorrow. Do you have the time to look at the sources? The native part is not big at all. And the managed part just calls an initialize method and the add method. I don't want to call GC.Collect(), but it will be called eventually, so I tried it manually, and the application freezes.
Please tell me if it's ok with you to send the sources. The more I dig..the more I get stuck with this problem.
|
|
|
|
|
I can take a look at it. Send me an email via Code Project and I'll reply.
Mark
|
|
|
|
|
|
System.Windows.Forms.SystemInformation.VerticalScrollBarWidth;
led mike
|
|
|
|
|
I don't mean this in a cynical way; if it's a good choice for my scenario, I'll use it.
It seems like I could make use of it if I'm writing, say, a checkout app: customer comes in, does some shopping, comes to the counter, the clerk scans all the barcodes, asks if the customer has a point card, prints a receipt, saves the transaction and marketing info to the database.
But I still can't quite put my finger on why it would be better to use Workflow Foundation than to just do all this by wiring a database to a client UI using LINQ to SQL. Any ideas?
Thanks in advance,
Rei
|
|
|
|
|
Not all applications are "Collect data in a webform, shove in database".
When you are trying to manage collection and approval of say purchase orders, assignment of stock allocations, matching of berthing locations to ships and then booking of product transfer equipment, all with different stages of approval in some management chain with loads of business rules, then it gets a bit more complex. You want all this fairly easy to change later (When someone says any loading over 5mt needs to be approved by someone with certain qualifications, etc).
Also who wants to spend time writing their own workflow solution? :P
|
|
|
|
|
So let me get this straight: it's good when there's a really complex/volatile business process that happens to involve a lot of computer check-ins/check-outs, and you want to model your entire application in the context of the business process whilst making it maintainable in case the business process changes later on. Right?
In other words, if there isn't much logistics, skip WF.
Okay, thanks
|
|
|
|
|
Yep. If there isn't much workflow, then skip WF
|
|
|
|
|
I have tried to search for this answer online but my searches are not finding it.
I want to launch a program from my code and pass it args. Similar to a command line. I need to do this in my VB .net code.
Does any one know how to do this or where I can read up on it?
Thank you.
|
|
|
|
|
You can use Process class for your needs.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thank you. I have a questions though. How do I pass it a command? The full command line is
"C:\Program Files\LV8\lv.exe" /CMDM "C:\Program Files\LV8\lbl\CMD\"
I can do
myprocess.start("C:\Program Files\LV8\lv.exe")
But I can't put the command after it.
Do you know how this is done?
I found it out. It is
myprocess.start("C:\Program Files\LV8\lv.exe", "/CMDM C:\Program Files\LV8\lbl\CMD\)"
|
|
|
|
|
Cory Kimble wrote: Do you know how this is done?
No, no one knows how that is done, and if anyone did know it certainly would not be Microsoft, and they certainly would not document it.[^]
So three hours after your original post you are asking for information that is freely and almost instantly available in the documentation. Let's see, at this rate you could write an entire application in a about a gazillion years. Good luck!
led mike
|
|
|
|
|
Replace the auto-generated main procedure with: sub main (string[] args){}
However this should have been a quick google problem.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Hi
I received this requirement.
- A telephone user will call a number. The number is connected to a system which will prompt for user authentication.
- It may be userid/passwrod authentical or a unique word authentication. This will be only known to the user. It can be changed via phone or through a web-interface.
- If could not authenticate in, let's say 3 times, then account is locked and user will have to request unlocking or do it online.
- If properly authenticated, then user will be redirected to a queue and next available operator will handle the user.
- System will open the default application screen for Operator. This screen will have prefernces set by the user
This seems like a regular telephone answering system but I don't have technical idea of creating such system.
I am looking for following help:
- What are the options for such needs?
- Are there any .Net based solutions to this? or any other technologies?
- What are the things I need to consider for such systems? Ofcourse security is the TOP priority.
Please advise. Thanks
Pankaj
|
|
|
|
|
can any body tell me how to add a form to a panel using C#.NET.
Thanks in advance.
Reagrds:
Biswajit
biswajit nayak
|
|
|
|
|
Surely you mean add a panel to a form?
|
|
|
|
|
"Form" is inherited from "Control", so you can use panel.Controls.Add(yourForm) . But it looks strange, why you are doing this ?
|
|
|
|
|
You could use the SetParent WinAPI command (google it). However, embedding a form in a panel makes the form immune to other general window events. You will not be able to move the window or interact with the titlebar.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|