The new version of Ghostscript (9.07) has a threading support (can be thread-safe), but it says that the code must be compiled with a special flag to enable this.
How do I do this? Or where can I get already built thread-safe version?
I tried to download the source, opened in VS, but it failed to build. So maybe somebody has already done this and could share the DLL.
Are you interested in the thread safe version of Ghostscript, or multiple rendering threads?
Multiple rendering threads are only of use if you are producing high resolution output, since the code must first interpret the PostScript program (or PDF file) and create a display list for the rendering threads to operate on. Unless you are rendering to a reasonably high resolution, this will actually be slower than using page mode (whole page rendered in memory)
You can create multiple rendering threads in the pre-built version of Ghostscript using the -dNumRenderingThreads switch.
If you want a thread-safe version of Ghostscript then you will need to be able to compile Ghostscript yourself. What version of Visual Studio are you using ? I am using Visual Studio 2005 and 2008 and the supplied solution works for me (after appropriate conversion).
I was looking for solution for this problem as well and eventually I solved it in Linux. Maybe it will help someone who comes here looking for solution.
Open terminal in sources directory and type this command:
./configure --enable-threadsafe
After that you can do make or make so for lib.
Here is link to docs for building ghostscript from sources: https://www.ghostscript.com/doc/9.23/Make.htm#Makefile_overview.
Take a look at Ghostscript.NET managed Ghostscript wrapper which allows you to run multiple instances of Ghostscript library at a same time if you have a need to process multiple pdf's at a same time.
Related
I want an auto updater that detect modified game files (by comparing files on the client-side and a server) and only download modified files.
The scenario is that there's about one thousand clients in a network, that use same application. If a new version of the application is available, they all have to get the new version.
I see a www.aldera.to game if you install the files their Aelra_patcher application auto patch the files from the server side. It do the exact thing I want:Getting the newest files from server when the patcher is run. But the problem is that clients wrote in C#, and I can't use IcePatch2 inside my application.
So far, the best solution I found is to get .NET Application Updater Component and customize it to fit my needs. But I prefer a solution that dose not require me to maintain another application.
Any idea?
Managing file locks is fairly simple. The process should go something like this:
The game application downloads the installer, if there is any
The game application runs the installer and exits
The installer starts doing the work of updating files as needed. If any files are locked it may wait a short while and try again, or ask the user if it is ok to close the application that have locked the files.
But the topic of minimizing update time and bandwith is a fairly complex. You might want to read Raymon Chens articles on Windows Update Formats to get some appreciation for the various issues.
I'm not familiar with IcePatch2, but it seems to be a fairly generic file synchronization tool. This may be appropriate for your specific use case, but I would expect some use cases to benefit from a more specialized approach. You could for example use knowledge of things like file or resource versions to avoid much of the work a more generic tool has to do.
My app is a WPF application and it already has code for the older type of System DPI awareness that works well in every version of windows except 8.1. It turns out that Microsoft added a number of functions to Windows 8.1 as part of their implementation of per-monitor DPI awareness. I need to implement code in my program to support this type of DPI awareness.
I have documentation that lists the per-monitor DPI awareness functions and what their parameters are. I need to import those into C# and call them from my window class. But I don't know which DLLs contain those functions! The documentation for the GetProcessDpiAwareness function, for example, does not indicate which DLL it's in.
How do I find what the exports in the DLLs are?
Right out of head, a dumb method: a binary search in C:\Windows\System32 for GetProcessDpiAwareness, then studying each occurrence with Dependency Walker for exports.
This produces the result: GetProcessDpiAwareness is exported by SHCore.dll.
One may also search the Windows SDK headers and libs, but in my case I haven't found GetProcessDpiAwareness, to my surprise.
Another idea, run the following from the command line prompt:
for %f in (%windir%\system32\*.dll) do dumpbin.exe /exports %f >>%temp%\__exports
Then search %temp%\__exports for the API.
I know it's been asked a while back. (Every time I Google it, this question comes up. So let me share my method.)
If anyone wants to search for functions in DLLs, there's this tool that will do it for you. In case of the GetProcessDpiAwareness on my Windows 10 (64-bit) it is exported from shcore.dll like someone had already mentioned above. Here's the screenshot:
Although I need to preface it by saying that it would be always prudent to refer to the function's documentation on MSDN instead. Currently you can find it at the bottom of each page:
If you play around with the search that I showed above, you will notice that many of the system functions are exported from multiple DLLs (some of which are undocumented.) So if you just blindly go with whatever you find in a search app, you may run a risk of breaking your program in the future if Microsoft changes one of those undocumented functions. So use it only for your own research or curiosity.
Usually functions that work with the same resources are in the same dll's. Look at another dpi function like GetDpiForMonitor and you will see it is in Shcore.dll
Edit: After you find the dll this way you can double check using dependency walker to see what functions are exported from that dll.
I'm using SharpDevelop to create a WinForm-based C# application. After studying my target audience, I believe it is in my best interest to use a no-install application. While creating my HelloWorld! program to get to know SharpDevelop (I have just switched from VBExpress), I found that the file it outputs is a .exe without any setup process. However, I'm worried that some of the features I want won't be compatible with this format. I don't want to get deep into this app and find out users are going to have to keep the program in the same directory as 548 other random files.
Here are the features I'm concerned about:
+Save user data (XML) in AppData.
+Access internet feeds (XML and/or JSON).
+Minimize to tray on close.
Also, are there any common pitfalls with this type of deployment method?
EDIT: I understand the enduser will need the .NET framwork for C# programs. I am not worried about this.
It will execute with the same privileges.
The only thing you will want to look out for is making sure the end user has the correct .NET framework installed since you don't have an installer to do that for you. But now reading the end of your message it appears you already have that covered.
If you are concerned about the deployment technique you can test it on a non-dev machine, though the results should be the exact same.
I am getting a pretty common, "The process cannot access the file because it is being used by another process."
Now I am nearly certain that the only process accessing this file is from code that I have written and I've been careful to use a using statement around accessing it.
But to be 100% sure, is there anyway to check this programatically when this error occurs?
There is also a small tool handle.exe in Sysinternals Suite that does exactly what you need. Use it from the command line:
handle.exe -a <filename>
Of course under Vista and Windows 7 this tool must be run elevated.
e.g. oh.exe from the Resource Kit and Process Explorer from sysInternals both show who is using what
Both of them use techniques not available in C#.
Windows Vista adds a new function, GetRunningObjectTable which you can use to detect which program has a file open. This only works in Vista+, and it only works when the application that has the file open actually implements supports for IFileIsInUse (e.g. Office supports it, but most 3rd-party apps probably don't).
Other than that, the usual way this is implemented is by opening each process, enumerating the file handles they have open and searching for the filename in question. This is pretty low-level, and would require quite a bit of P/Invoke to implement in C#, but it's not impossible.
It's usually easy enough just to open up Process Explorer and let it do the search.
I need to create a sound containing tones of many different frequencies. Is there any way to do this in C#?
The only tone generating methods I've seen so far involve console.beep, which works, but only for pure tones (single frequencies).
The Audiere library makes this extremely easy to do. Here's a nearly complete C# program to generate the DTMF tone for the "1" button:
AudioDevice device = new AudioDevice();
OutputStream tone1a = device.CreateTone(697); // part A of DTMF for "1" button
OutputStream tone1b = device.CreateTone(1209); // part B
tone1a.Volume = 0.25f;
tone1b.Volume = 0.25f;
tone1a.Play();
tone1b.Play();
Thread.Sleep(2000);
// when tone1a stops, you can easily tell that the tone was indeed DTMF
tone1a.Stop();
To use Audiere in C#, the easiest way to get up and running is to use Harald Fielker's C# binding (which he claims works on Mono and VS; I can confirm it works in the both full version of VS2005 and using the separate Express 2008 versions of C# and VC++). You'll need to download the Win32 Audiere DLL, lib, and header (which are all in the same zip) and you'll need to build the C# binding from source using both VC++ and C#.
One of the nice benefits of using Audiere is that the calls are non-blocking. You don't have to wait for tone1a to stop playing before you start tone1b, which is clearly a necessity for playing complex tones. I am not aware of any hard upper limits on how many simultaneous output streams you can use, so it's probably whatever your hardware/OS supports. By the way, Audiere can also play certain audio files (MP3, WAV, AIFF, MOD, S3M, XM, IT by itself; Ogg Vorbis, Flac, Speex with external libraries), not just pure generated tones.
One possible downside is that there is a slightly audible "click" as you start or stop an individual tone; it's not noticeable if you add one tone to an already playing tone. The easiest workaround I've found for that is to slowly ramp the tone's volume up or down when you're turning the tone on or off, respectively. You might have to play around with the ramp speed to get it to sound "just right".
Note that Audiere is LGPL-licensed, and the binding has no license attached to it. You'll have to consult your legal team or try to get a hold of Harald if you want to use his binding in a commercial product; or you could just make your own binding and avoid the hassle.
#Tom: Since there is no specific license attached to Harald's library, I'm not sure what implications would come of hosting it; however, I believe I can at least give you fine detail on exactly how my libaudieresharpglue project is set up.
Using Visual C++ Express 2008, open up bindings/csharp/libaudieresharpglue/vc8.0/libaudieresharpglue.sln. VC++ will automatically convert the solution to a VS9 solution.
In another folder, you should have the Audiere package from Sourceforge. Under your VC++ project properties, go to Configuration Properties > C/C++ > General, and make sure you have path/to/audiere-1.9.4-win32/include in your "Additional Include Directories." Then, in that same window, go to Linker > General and make sure you have /path/to/audiere-1.9.4-win32/lib in your "Additional Library Directories." Then, you should be able to build the project (preferably in Release mode) and this output libaudieresharpglue.dll in your vc8.0/Release folder.
Next, open up Visual C# Express 2008. Open up bindings\csharp\test\vc8.0\AudiereCSharpTest.sln and let it convert the solution. The project should build fine, but then you will get an error when you run it. That's fine; in your csharp/test/vc8.0/bin/Release folder, you need to add both libaudieresharpglue.dll from the VC++ solution and audiere.dll from the package from Sourceforge.
Now, you should be able to build and run AudiereCSharpTest. Note that by default, #define stream_test is not commented out at the top of AudiereTest.cs, and that will reference a file that is not on your hard drive. You can simply comment out that #define and uncomment noise_test or square_test.
That should cover it; if I missed any details, hopefully they are small enough to get by on your own :)
You can always try DirectSound...
I have been looking at NAudio with the view to create a program that emulates feedback whilst playing a backing track. There is a blog post about generating sine waves at specific frequencies, I suspect that this could be adapted to do what you are looking for.
Yes it is possible.
Here is a link to a tutorial on this. but of course this also uses Console.Beep
The MSDN documentation doesn't make it clear if Console.Beep is asynchronous or not. If it is, you can probably fire off as many calls as you need in quick succession and nobody will be the wiser. You'd want to use the version that takes a frequency and a duration, of course.
Essentially, you have to implement your own software synthesizer or find a 3rd party library. See: http://en.wikipedia.org/wiki/Demo_(computer_programming)#Music