c# - 如何从我的控制台应用程序打开多个 http 链接?
问题描述
我创建了一个控制台应用程序,我想在特定时间触发多个链接。搜索后我做了这样的事情:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace cronjob_Test_App
{
class Program
{
static void Main(string[] args)
{
StartProcess();
}
public static void StartProcess()
{
// Process.Start("https://notepad-plus-plus.org/repository/7.x/7.5.7/npp.7.5.7.Installer.exe");
var psi = new ProcessStartInfo("chrome.exe");
string a, b;
a = "https://notepad-plus-plus.org/repository/7.x/7.5.7/npp.7.5.7.Installer.exe";
b = "https://notepad-plus-plus.org/repository/7.x/7.5.7/npp.7.5.7.Installer.exe";
psi.Arguments = a;
Process.Start(psi);
psi.Arguments = b;
Process.Start(psi);
}
}
}
它同时启动所有链接。我希望第一个链接完成,然后启动第二个链接。我该怎么做,或者如果有其他好的方法,请建议。我正在使用 Windows 调度程序和这个控制台应用程序在特定时间启动控制台应用程序。
解决方案
你可以试试这个。使用 useProcess.Start
并将 url 设置为第二个参数。
string a = "https://notepad-plus-plus.org/repository/7.x/7.5.7/npp.7.5.7.Installer.exe";
string b = "https://notepad-plus-plus.org/repository/7.x/7.5.7/npp.7.5.7.Installer.exe";
Process.Start("chrome.exe", a);
Process.Start("chrome.exe", b);
推荐阅读
- javascript - 不包括 node_modules 的 Glob 文件模式
- swiftui - SwiftUI:QuickLook 在 iPad 设备中无法正常工作
- typescript - 从泛型类型推断返回类型?
- api - 请求完成后访问 DI 对象。ASP.NET 核心 2.1
- annotations - 如何将 nginx-ingress 注释转换为 --set 格式以启用 prometheus 指标
- python - 使用 if else 在 Jupyter 中创建海运图时出错
- c# - 将 groupfunction 动态传递给 Linq 查询
- javascript - 如何在 Node.js 和 Angular 中高效地创建“产品过滤器”?
- line - Halcon - 移动 XLD 线
- r - R:为多个不同变化的参数评估函数