I have a C# Console Application which communicates trough its Input and Output with another application. This isn't a thing that can be changed so thats the given part of the problem.
The other part is that I need a way to communicate with this Console Application. Google says WCF, REST and stuff like that but this to me seams a little bit overkill cause I only need to communicate locally to the Console Application.
I also tought of communicating trough a file with that application but than I would have to check the file in an interval for changes right? Also I'm not sure if this is performance wise the best solution? Also i would have a delay, befor the notification happens depending on the interval.
So what would be a neat way to communicate between to local applications?
To achieve this use need to implement socket communication in your application. Below link will give you an idea on how sockets works in c#
http://csharp.net-informations.com/communications/csharp-socket-programming.htm
Related
For a while I've been trying to think of ways to achieve a simple task: I have two background tasks in my app, and I want one to notify the other about certain changes (only one-way communication required), but for the life of me I can't figure out any way that works. These are the methods I found from the internet, but all of them have issues:
I thought I could create a simple text file in the local folder of the app and put the notifications there. The listening process could somehow subscribe to that file and be notified of any changes in its content. This was achievable previously with the FileSystemWatcher class, but it was removed from Windows 8 onwards.
Then I found another API for implementing the above method, namely the QueryOptions class. But it turned that while it's available in Store apps, it's not supported on Windows Phone.
I thought about using push notifications, but they're all linked to a web service. As of yet I can't figure out any way to use them to send and receive notifications locally without a web server.
Is there any way to go about doing this? It seems like a very straightforward task but it's turning out to be impossible to achieve. Is there any other API on Windows Phone that allows a process to be notified when the contents of a file are changed? Or is there any way I can work around with push notifications and achieve this? I also read in places that named pipes and sockets are often used to achieve this kind of functionality on other platforms, is there any way to apply this here?
Short of polling the text file for changes every half a second or so (which would be highly inefficient and introduce lag which is something my app can't tolerate), I can't figure out any other way to achieve this task.
Thanks in advance.
If you want a general-purpose IPC mechanism across two or more processes in the same app, you can look into this sample which wraps Win32 IPC primitives.
There is no way to "wake up" a process (or start a background task) when a file changes. So this only works if the processes will be running at the same time (if they're not running at the same time, you can use some other sort of signaling mechanism, such as a placeholder file on disk).
There is also no way to signal across two different apps; you have to round-trip via the network for that (eg, one app pings a server that relays it to the other app).
I have encountered a difficulty while trying to figure out how certain aspect of my program will work:
(There is no code written at the moment, only concept).
I have a PC application which I want to build with C#.
In addition I have few android devices with my java application on it, which will be dependent on the PC application but will have its own functionality.
The android application will have to read data from the PC application and vice versa as well.
At first I thought creating a server which all applications will read from.
But now I'm thinking maybe there is a easier, less complex way (since I have no idea about accessing to servers and I'll have to learn the entire thing) - creating a network and shared folders - now the PC application will save his data at the shared folders and the android application will read the data from the shared folder, every 5 minutes or something like that or create a listener that will update the application upon any change made by the PC application.
The android application will have to do the same, save his data at the shared folders and let the PC read from the shared folder.
Basically, this is my idea, now my question are:
What do you think about the implementation of the idea?
Is it possible to access shared network folder with android device?
Is it possible to add android device to home network?
The combination of C# PC application and java will be alright?
Thanks in advance.
Answer of your questions :
This idea in implementable surely
I do not know for sure , but it should be .
Yup , it's very much possible using a WiFi connection.
This will not a problem as you have to use Webservice/Socket Programming (i will prefer for socket) where multiple platform is not a problem at all :)
Happy coding :)
I have an .exe that runs on my computer. How can I connect to it from c#?
For example notepad.exe is running. I would like to write in notepad from windows form app or console app form. How can I do that?
Two suggestions:
either start the process using Process.Start()
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
or use SendKeys from Windows Script Host
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
It depends on exactly what you want to do. Using SendKeys is the simplest solution but it's crude and limited in functionality. You can do more and better with SendMessage, but this will be harder to code.
Have a look at this tutorial. As far as I can tell, it does exactly what you are looking for. I realize it's in German, so just look at the source code.
Reading from another process in windows is problematic to say the least. We did some work on this a while ago and it involved hooking into the low-level Win32 API using assembly language. Essentially, it's really not pleasant and if you can avoid doing this you'll have a lot more hair on your head.
Using SendMessage would work if the application you are sending to understands the message you are trying to send to it. I suspect that you start to get into security problems with this on later Windows versions (Vista + Win7) and would have to run your application with elevated privileges.
Why do you want to do this?
My class was recently assigned a group project to be worked on over the next 5 or 6 weeks. It is largely complicated, but a specific item I need to work on involves a chat feature. To keep it simple, there will be about 5 workstations hard-wired together at an event, and they need to be able to communicate instantly.
Our idea is to just throw an executable on each of their computers, so the chat functionality needs to be built-into the application. In order to keep conversations clear and uncluttered, we are going to have a group chat as well as individual chats. I have no way of displaying the GUI we are shooting for, but basically a window will be split in two. On one side a list of workstations as well as a group option will appear, and on the other the actual chat window.
As an aside, I would like to add a notification feature to it so that an alternate tab of the chat will blink, show a star, or something to that effect.
Long story long, I need ideas on how to implement this chat system within an application. It's got me stumped.
Windows Communication Foundation would be a good choice for the network communication portion. There have been many WCF chat servers written - for example, see here and here. One of these examples could get you started.
how about this for a starting point. If you need help code project is a good place to start if you have specific requirements
http://www.codeproject.com/KB/WCF/WCFWPFChat.aspx
Heres a tutorial How to create a remote server by using Microsoft Visual C# that should get you started.
I want to work on windows API. I have an interest in creating network application that can communicate with web as well. I haven't thought any application yet. But before doing all this . I want to know where to start with. What all I need to start reading.
I have created lot of database interactive applications with window forms. But would like to start with this.
If you want to use Windows API methods from .Net, you'll need to use PInvoke to call them. There's a site called pinvoke.net that has samples for how you call many of the APIs so if you know which API you want to call, that's usually the best place to start.
For your use case maybe you dont need API at all. You could use the FileSystemWatcher .net class to react on any changes in a log folder e.g. It reacts on modify/add/delete of files.