|
That will work for that one particular file, but the app in question writes a bunch of files and folders inside the folder he's talking about. Managing watching all those files would be pretty chaotic.
|
|
|
|
|
Well, I figured he is already looping through all the files with is FileInfo loop. I figured it isn't much different then waiting 45 seconds and checking again to see if the size has changed. Anyway, it is the only way I know of, that ensures that the file is not still being written. That is usually the bigger issue. You don't want to try and process a file that is still writing to the folder you are looking at.
Ben
|
|
|
|
|
I'll look into your suggestion, Ben...thanks for the advice.
|
|
|
|
|
But it doesn't work if the application is writing to several files simultaneously or writing to the files intermittantly. Open the file, write, close, ..., rinse and repeat. Logging libraries do this frequently.
I know the technique you're talking about. I've figured out, the hard way, that it doesn't work all the time.
|
|
|
|
|
Would FileSystemWatcher help?
|
|
|
|
|
Hi,
I am stuck with one of the basic question on .Net Framework.
Regarding Serialization, I know that it is the process of converting objects into a stream of bytes inorder to store the status into a storage medium. De-serialization is just the opposite. But my question is, in real time, where exactly we require the serialization? At what point of time we choose seriaization?
Can anybody who knows please reply. Any help would be great.
Thanks
Meeram395
|
|
|
|
|
Most of the time I use serialization, I am serializing objects to xml. Then this xml is saved in a sql database. Later when the order is looked at, the state of the order can be retrieved by taking the xml that was saved and de-serializing it back into the original object.
Hope that helps.
Ben
|
|
|
|
|
Serliazation is used for such things as viewstate in ASP.NET or for transport in .NET remoting or Web Services, or any other interprocess communication.
only two letters away from being an asset
|
|
|
|
|
Serialization is simply the act of taking an object in memory and converting it to some format that allows it's internal state to be saved (persisted) and recreated later (either a a later point in time, on a different computer, or both).
Serialization is used in a lot of situations. Serialzing to XML is a way to persist the object to a databse or transfer it through remoting to another system. If you don't have a need to persist or transfer the data, then you don't need serialization.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi
The real use of serialization is in object usages. For instance I have a object named Person. And i am keeping informations like name, address, salary etc as members of that object. Then if i need to persist it and later i need it in same form. Then we can use serialization to keep that object for future use.
Gg
|
|
|
|
|
Hi,
Can anybody tell me where can i get sample code / demo for the
Application Blocks in Enterprise Library...
If You have with you ...can you pls send it to me...
Thanks in Advance,
with regards,
Bommannan.Ramalingam
Nothing can be Done by Changing the Face. But, Anything can be Done by Facing the Change.
|
|
|
|
|
here[^]
only two letters away from being an asset
|
|
|
|
|
I'm trying to print in WPF without showing the WPF PrintDialog control. It seems crazy, but I can't figure out how to enumerate all available printers. In other words I want a PrintQueueCollection of all accessible printers on the machine (or a way of enumerating all usable PrintQueues). All the examples and code I see only allow you to enumerate local printers, or the printers on a specific remote server. I just want to get the printers set up on the machine, as shown for example in "Printers" in the Control Panel. Seems easy, anyone have a code snippet?
Thanks,
Jeff
|
|
|
|
|
Have you resolved this? Or looked around at the WPF articles here. Josh Smith might be the guy to ask.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Yes, I resolved it, thanks. It was just a matter of passing "Connections" and "Local" queue types to GetPrintQueues.
Jeff
|
|
|
|
|
Hello,
I am currently developing an application that will serve as a client interface for a Rimage cd-producing server. This application is intended to run on the same Windows box that the Rimage is connected to and monitor a directory on the file structure or network for folders (patient studies to be burned to cd) that are sent there to be processed. Once a folder is detected in the target directory, that folder is moved to a temp directory, where an order is created and the processing begins.
The process for the order is managed entirely within a worker thread, and each order gets its own thread to run in. The thread method contains a WHILE loop that cycles until the order's state property is set to indicate completion. Inside this loop are sets of conditionals that move the order along as the order's state is advanced by the server. Once the order is done the loop exits, and a cleanup routine is executed that removes the files that were processed and other completion-related tasks (logging, UI updating, etc).
I have a couple questions related to my design that I'm hoping a more seasoned developer (read: anyone) might be able to answer and possibly point me in a better direction (read: something that actually works).
1) In the order detection process, when a folder is found in the target directory, I load that folder into a DirectoryInfo class and check the LastWriteTime property. If LastWriteTime.AddSeconds(10) < DateTime.Now , I move the folder for processing. If not, the folder is left alone until the next pass, during which it will be checked again. The objective of that check is to make sure that all contents to be burned have been copied over before the order process begins.
This has usually seemed to work fine, but lately when I test using larger folders of data (+100megs), the folder will be sent for processing before the files are done copying.
My question is: does the LastWriteTime (or even LastAccessTime, for that matter) account for any subfolders inside the folder being written to or does it only check for files being written to in that particular folder, ignoring any subfolder activity?
2) In the method that the worker thread runs, the constantly cycling WHILE loop doesn't seem like the best way to do it. However, the thread needs to stay alive through two different processes; the first process that tells the Rimage to create an ISO image of the files and the second process that sends an order to the Rimage to burn that ISO image to a cd. So having the method loop while it worked its way through those processes seemed the best way to do it at the time. Upon further reflection, I'm sure there's a better method than that to manage multiple orders independently while not tying up my UI thread and making my form non-responsive...I just don't have a clue what it is and a lot of the tutorials that I've looked at just don't seem to fit with what I'm trying to accomplish here.
In case you couldn't tell by now, I'm a very inexperienced programmer (read: HTML monkey/Layout guy) that has been assigned with this project. Kind of like learning to swim by being tossed in the middle of a lake. With an anvil around your ankle. And sharks. I would really appreciate any guidance or links to resources that some kind-hearted guru can provide that would help with the above issues.
Thanks in advance.
|
|
|
|
|
1 - you could check the size of the folder with subfolders, then check it again a few seconds later to see if it's being writtn to. Also, if it is being written to, attempts to rename it will fail.
2 - You need to create a BackgroundWorker thread, and then keep that alive, if need be.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
1 - you could check the size of the folder with subfolders, then check it again a few seconds later to see if it's being writtn to. Also, if it is being written to, attempts to rename it will fail.
Thanks for the idea, I think that will work better than what I'm using now.
2 - You need to create a BackgroundWorker thread, and then keep that alive, if need be.
Maybe I don't understand exactly how the BackgroundWorker class works, but doesn't each BackgroundWorker only run one thread at a time? And if this is the case, and my application needs to be able to process orders as they are dropped in the target folder, wouldn't I have to create a new BackgroundWorker for each order? Would this be a heavy performance hit on the server's memory with all those components being created (in the case of say...20 orders...are submitted at the same time), as opposed to just launching threads to run it and keeping it alive via the loop?
|
|
|
|
|
Well, I was saying you could keep the one thread alive, but if that's your goal, then there's no reason not to create a thread for a new job, and let it die when the job ends. Then you can either choose to only have one thread running ( and have a job queue that it keeps pulling from until it ends ), or have multiple jobs going ( not likely, as I believe you have one piece of hardware to control, right ? )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If I'm understanding this correctly, your solution would make it so that there was only one order being processed at a time, with the thread constantly cycling and picking up the next order in line once the previous order is finished. If we were simply interfacing with a direct piece of hardware, that would work...
However (and I apologize for not mentioning this and causing the confusion), I am programming this to work with an established API from Rimage, and my client software is actually connecting to a software-system as opposed to directly to just one machine. Theoretically, there could be as many actual Rimage servers attached to the system to process 20 orders at once, and their software has its own queue internally. My application simply prepares the order, sends the ticket and monitors the status via a listener class that inherits an interface of their design. By designing each order to run in its own thread, I was attempting to maximize the use of their internal queuing system as well as the efficiency of my own program. Technically, I should be able to throw as many orders as possible at the API and it will manage the workflow on the server side...I just have to monitor the status on my end of the orders that I send.
My question regarding the threading was really me asking if there was some way to make the process that runs in the thread more event-based instead of so rigidly set inside of conditionals. Say, for instance, if I were to create events on the order object and assign handlers for those events from inside the worker thread to progress the order along, and then didn't loop the worker thread to keep it alive, the thread would just exit and those handlers would just fire into nothingness? Or would they fire on the main thread and cause exceptions because the handlers were declared inside a thread other than the UI thread and caused UI interaction indirectly when the handlers were called and the UI was updated with results (which I know enough to know that is a big no-no)?
I don't know...I've been pondering over some of these things for a few hours and been doing some more searching on the web for answers. I think I might have thought of something that will make this whole project a lot easier, but I have to flesh out the idea in the morning to make sure I'm not overlooking something...if it works, the whole threading issue might be moot.
Thanks for the advice so far, though...most assuredly this is not the end of my stupid questions
|
|
|
|
|
Don't keep worker threads alive, just create threads as you need to, one for each job. You can create a thread pool, just create a container of threads, and look through for an idle one to start, if you want a fixed number, or keep adding to it if you're happy for there to be unlimited threads.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all,
I want that the dll of my application which are on the client machine after deployment should be protected that no one can see the code and logic using some deassembler tool. How should i protect this???
i tested a third party tool to read a dll of some trial version application from internet. Its opens the code easily, but when i tried the same tool with some system32 dll, the dll showed to be locked. I want this to be in my dll also. How is it possible ???
Sample Code, Suggestion, References welcom ........
Thanx
sandeep
|
|
|
|
|
sandeep kumar pundhir wrote: How should i protect this???
You can't. If the processor can run the executable, there will always, at some point, exist an unprotected version in order that it can be sent to the processor. Therefore there must be some way to decrypt the code for the processor, and once that is cracked then you have no protection at all. The best you can ever hope for is to slow down someone.
sandeep kumar pundhir wrote: i tested a third party tool to read a dll of some trial version application from internet. Its opens the code easily, but when i tried the same tool with some system32 dll, the dll showed to be locked.
Define "locked". Could it be that the DLL you were using was not a .NET DLL and the tool could not interpret it.
|
|
|
|
|
Please don't cross post.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You used a tool, probably .NET Reflector to look at a .NET DLL. This is exactly what it's good for. .NET Reflector won't work on native code .DLL's, like on just about everything in the System32 folder.
What you want is not possible with a .NET DLL, or any managed code assembly for that matter. You can obfuscate the code and make it more difficult to be reverse engineered, but you cannot stop anyone from eventually getting at that code.
|
|
|
|
|