使用Renci的sshnet库,我无法在上传文件时处理连接问题.
如果我在UploadFile上设置了一个断点,禁用我的连接,让它运行,它只是挂在那一行上.这些是慢速连接上的潜在大文件,因此添加OperationTimeout将很困难.
此外,这在一致的连接上一遍又一遍地工作.有任何想法吗?谢谢!
AuthenticationMethod[] methods = new AuthenticationMethod[1];
methods[0] = new PasswordAuthenticationMethod(username, pwd);
var con = new ConnectionInfo(Config.RemoteHostName, username, methods);
con.Timeout = new TimeSpan(0, 0, 0, 30);
var client = new SftpClient(con);
client.Connect();
string fullFilePath = string.Format("{0}{1}", Config.RemoteFilePath, filename);
client.BufferSize = 15000;
client.UploadFile(new MemoryStream(buffer), fullFilePath);
client.Disconnect();
Run Code Online (Sandbox Code Playgroud) 我在两个表之间有一个标准的多对多关系,使用第三个链接表进行链接.无论如何将链接的id连接到一个带有查询的记录中?
我意识到我可以处理一个典型的连接并用它构建一个新的列表,只是想知道它是否可以用查询完成.例:
EventID | EventName | EventTypeIDs
1 | Party | 1,2,3
Events
+-------------+-------------+
| Field | Type |
+-------------+-------------+
| EventID | INT |
| EventName | varchar(45) |
+-------------+-------------+
EventTypes
+-------------+-------------+
| Field | Type |
+-------------+-------------+
| id | INT |
| value | varchar(25) |
+-------------+-------------+
EventTypeLink
+-------------+-------------+
| Field | Type |
+-------------+-------------+
| id | INT |
| EventID | INT |
| EventTypeID | INT |
+-------------+-------------+
Run Code Online (Sandbox Code Playgroud) 我将从.NET重新使用C,因此请原谅我的代码,但是我试图在现有的多进程程序中实现原子内置的增量器。
我写了一个测试程序,但无法正常工作。正确地将其增加到5,但是每个子级将值增加到6,而不是将其总和增加到10。监视器显示5。
我已经尝试过使用全局int进行各种更改,而不是将static int从main传递给子级,但是结果相同。任何帮助表示赞赏,谢谢。
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include "list.h"
7
8 #define N 5
9 static int globalcount = 0;
10
11 void Monitor()
12 {
13 sleep(1);
14 printf("Monitor Value %d\n", globalcount);
15 }
16
17 void Child()
18 {
19 int value = __sync_add_and_fetch(&globalcount, 1);
20 printf("Child Value %d\n", value);
21 }
22
23 int main(int argc, char** argv)
24 {
25 int i;
26 …Run Code Online (Sandbox Code Playgroud)